Umano Android slidinguppanel – animation
I am using the following items: https://github.com/umano/AndroidSlidingUpPanel
It works very well so far, but I have a problem: I want to hide the slidable panel until I press a button, and then the panel should fade in with animation; The panel is currently displayed when the button is pressed, but there is no animation. I don't know how to realize the animation
Any idea will be very popular!
resolvent:
I know you've been asking this for four months, but I decided to release an answer (so others may benefit from it)
The fading of slidable panels is relatively easy. You only need to start alphaanimation on the layout representing slidable panels. You may need to disable panel shadows by adding
sothree:shadowHeight="0dp"
To the main layout in your XML
More interestingly, when you want to expand the sliding panel from the bottom of the screen (if the panel is anchored at the bottom). In this case, you can use the following code:
import android.view.animation.Animation;
import android.view.animation.Transformation;
import com.sothree.slidinguppanel.SlidingUpPanelLayout;
public class SlidingUpPanelResizeAnimation extends Animation {
private SlidingUpPanelLayout mLayout;
private float mTo;
private float mFrom = 0;
public SlidingUpPanelResizeAnimation(SlidingUpPanelLayout layout, float to, int duration) {
mLayout = layout;
mTo = to;
setDuration(duration);
}
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
float dimension = (mTo - mFrom) * interpolatedTime + mFrom;
mLayout.setPanelHeight((int) dimension);
mLayout.requestLayout();
}
}
And start the animation by:
SlidingUpPanelLayout slidingUpPanelLayout = (SlidingUpPanelLayout) findViewById(R.id.id_of_your_major_layout);
int slideablePanelHeight = 100;
int animationDuration = 800;
SlidingUpPanelResizeAnimation animation = new SlidingUpPanelResizeAnimation(slidingUpPanelLayout, slideablePanelHeight, animationDuration);
mSlidingLayout.startAnimation(animation);