Android Open Source - MultiWork Expand Collapse Animation






From Project

Back to project page MultiWork.

License

The source code is released under:

Copyright (c) 2013, Torti Andr?s Fernando All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions a...

If you think the Android project MultiWork listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.tjerkw.slideexpandable.library;
/*  w  w w .j  ava2  s.  c o m*/
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.Transformation;
import android.widget.LinearLayout;

/**
 * Animation that either expands or collapses a view by sliding it down to make it visible.
 * Or by sliding it up so it will hide. It will look like it slides behind the view above.
 *
 * @auther tjerk
 * @date 6/9/12 4:58 PM
 */
public class ExpandCollapseAnimation extends Animation {
  private View mAnimatedView;
  private int mEndHeight;
  private int mType;
  public final static int COLLAPSE = 1;
  public final static int EXPAND = 0;
  private LinearLayout.LayoutParams mLayoutParams;

  /**
   * Initializes expand collapse animation, has two types, collapse (1) and expand (0).
   * @param view The view to animate
   * @param type The type of animation: 0 will expand from gone and 0 size to visible and layout size defined in xml.
   * 1 will collapse view and set to gone
   */
  public ExpandCollapseAnimation(View view, int type) {

    mAnimatedView = view;
    mEndHeight = mAnimatedView.getMeasuredHeight();
    mLayoutParams = ((LinearLayout.LayoutParams) view.getLayoutParams());
    mType = type;
    if(mType == EXPAND) {

      mLayoutParams.bottomMargin = -mEndHeight;
    } else {

      mLayoutParams.bottomMargin = 0;
    }
    view.setVisibility(View.VISIBLE);
  }

  @Override
  protected void applyTransformation(float interpolatedTime, Transformation t) {

    super.applyTransformation(interpolatedTime, t);
    if (interpolatedTime < 1.0f) {
      if(mType == EXPAND) {
        mLayoutParams.bottomMargin =  -mEndHeight + (int) (mEndHeight * interpolatedTime);
      } else {
        mLayoutParams.bottomMargin = - (int) (mEndHeight * interpolatedTime);
      }
      //Log.d("ExpandCollapseAnimation", "anim height " + mLayoutParams.bottomMargin);
      mAnimatedView.requestLayout();
    } else {
      if(mType == EXPAND) {
        mLayoutParams.bottomMargin = 0;
        mAnimatedView.requestLayout();
      } else {
        mLayoutParams.bottomMargin = -mEndHeight;
        mAnimatedView.setVisibility(View.GONE);
        mAnimatedView.requestLayout();
      }
    }
  }
}




Java Source Code List

com.bluetoothutils.andres.BTSingleSynchTransfer.java
com.bluetoothutils.andres.BluetoothHelper.java
com.bluetoothutils.andres.DeviceScanner.java
com.bluetoothutils.andres.OnBluetoothConnected.java
com.bluetoothutils.andres.OnDeviceSelected.java
com.bluetoothutils.andres.OnNewBluetoothDataReceived.java
com.frecuencimeter.andres.FrecView.java
com.frecuencimeter.andres.Frecuencia.java
com.multiwork.andres.ApplicationContext.java
com.multiwork.andres.LCView.java
com.multiwork.andres.MainMenu.java
com.multiwork.andres.MainPrefs.java
com.multiwork.andres.MenuListAdapter.java
com.protocolanalyzer.andres.AnalyzerExpandableAdapter.java
com.protocolanalyzer.andres.CRC16.java
com.protocolanalyzer.andres.LogicAnalizerPrefsFragment.java
com.protocolanalyzer.andres.LogicAnalizerPrefs.java
com.protocolanalyzer.andres.LogicAnalyzerActivity.java
com.protocolanalyzer.andres.LogicAnalyzerChartFragment.java
com.protocolanalyzer.andres.LogicAnalyzerListFragment.java
com.protocolanalyzer.andres.OnActionBarClickListener.java
com.protocolanalyzer.andres.OnDataClearedListener.java
com.protocolanalyzer.andres.OnDataDecodedListener.java
com.roboticarm.andres.BrazoRobot.java
com.roboticarm.andres.JoystickView.java
com.roboticarm.andres.Joystick.java
com.tjerkw.slideexpandable.library.AbstractSlideExpandableListAdapter.java
com.tjerkw.slideexpandable.library.ActionSlideExpandableListView.java
com.tjerkw.slideexpandable.library.ExpandCollapseAnimation.java
com.tjerkw.slideexpandable.library.SlideExpandableListAdapter.java
com.tjerkw.slideexpandable.library.SlideExpandableListView.java
com.tjerkw.slideexpandable.library.WrapperListAdapterImpl.java
com.utils.andres.ConflictChecker.java
com.utils.andres.Dependency.java
com.utils.andres.Pair.java