我有一个带有一些元素(A,B和C)的LinearLayout:
-------
| A |
+-----+
| B |
+-----+
| C |
-------
在开始时B是GONE(View.GONE),但当用户按下A时,B会显示动画:
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;
}
View B是动画的,但是View C只是跳到了最后,我想知道是否有一种标准的方式来动画B和C的方式,它们同时向下滑动< / p>
答案 0 :(得分:0)
您可以使用android:animateLayoutChanges属性:
<LinearLayout
android:animateLayoutChanges="true"
...
/>
以下是the link的更多信息。