Is there any idea or how can i achieve this Animation like following picture? because i tried to give a animation on Linearlayout B when i pressed a cancel button, the linearlayout B will slide out from left to right but once LinearLayout B fully Gone, the LinearLayout C directly step to below of LinearLayout A rather than slide slowly to below of LinearLayout A. please help...
问问题
1772 次
2 回答
2
设置android:animateLayoutChanges="true"
为线性布局,您将自动实现这一点。
于 2013-05-28T08:39:17.640 回答
0
首先在视图 C 中添加一个 ViewTreeObserver.OnPreDraw 监听器:
int bHeight = viewB.getHeight();
viewC.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
public boolean onPreDraw() {
viewC.startAnimation(new TranslateAnimation(0, 0, bHeight, 0));
viewC.getViewTreeObserver().removeOnPreDrawListener(this);
return false;
}
});
然后将 B 的可见性设置为消失。
viewB.setVisibility(View.GONE);
这样做是隐藏视图 B,导致视图 C 向上移动。然而,在 C 被绘制到它的新位置之前,我们将它从过去的位置动画到现在的位置。
于 2013-05-28T08:39:48.047 回答