I'm trying to make a really simple slide up list view, which is displayed when a user clicks on a button at the bottom of the screen. Here's how it should look:
And a complete implementation in HTML/JS http://jsbin.com/utAQOVA/1/edit
I've tried to use RelativeLayout
to position the list just below the button, and put that whole thing into a wrapper and then animate that up/down (same as in the JSBin above).
The problem is that the bottom part which isn't visible in the beginning is somehow clipped, even if I slide it up. Evern if I initially show a portion of the list as the screenshow below shows, the bottom part gets clipped when it moves up and only the part that was initially visible is displayed.
What would be a proper approach to do this kind of animation?
Here's a relevant portion of the layout
Edit: after a brief discussion (in the comments of the accepted answer) I've solved this by removing the wrapping LinearLayout
around the part that is animated and I simply changed height of the ListView
, which pushes the button up.
The problem you have might come form how ListView does its own layout, basically it fits itself to the size available on screen and paints that part and since you create the ListView without Height or very small height that the size it keeps. You can solve this with two approaches:
Adapted from a post I mentioned in the comments a ValueAnimator should look like this:
ValueAnimator va = ValueAnimator.ofInt(0, height);
va.setDuration(700);
va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator animation) {
Integer value = (Integer) animation.getAnimatedValue();
v.getLayoutParams().height = value.intValue();
v.setTranslationY(-value.intValue());
v.requestLayout();
}
});
The animation you're looking for would look like this.-
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@android:integer/config_longAnimTime"
android:fromYDelta="100%p"
android:toYDelta="0" />
You can run it storing it an animation xml resource, and doing.-
Animation anim = AnimationUtils.loadAnimation(this, R.anim.animId);
yourView.startAnimation(anim);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With