I have a LinearLayout with some elements (A,B and C):
-------
| A |
+-----+
| B |
+-----+
| C |
-------
And at the beginning B is GONE (View.GONE), but when the user press A, B is shown with an animation:
public static LayoutAnimationController getLayoutAnimation_slideDownFromTop(Context ctx) {
AnimationSet set = new AnimationSet(true);
Animation animation = new AlphaAnimation(0.0f, 1.0f);
animation.setDuration(100);
set.addAnimation(animation);
animation = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f,
Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF, 0.0f
);
animation.setDuration(300);
set.addAnimation(animation);
LayoutAnimationController controller = new LayoutAnimationController(set, 0f);
return controller;
}
The View B is animated propery, but the View C just jumps to the end and I would like to know if there is a standard way to animate B and C in a way that both of them swipe down at the same time
You can use the android:animateLayoutChanges attribute:
<LinearLayout
android:animateLayoutChanges="true"
...
/>
Here is the link with more information.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.