【发布时间】:2013-01-15 00:05:59
【问题描述】:
我有包含两个相对布局的框架布局,一个在另一个之上。当用户单击一个按钮时,顶部的按钮将屏幕向右移动 80%。然后底部的一个变成可点击的。这就是它的样子。
FrameLayout
RelativeLayout (bottom) RelativeLayout (top)
FilterWidgets Open/close button, ListView
在 3.0+ 上使用新的动画 api 很容易实现,它是基于属性的动画。对于 3.0 之前的版本,因为动画是基于视图的。所以我最终手动修改了 onAnimationEnd 上的布局属性。调用 requestLayout 使其永久化,但只是为了找出布局恢复到原始位置。有人知道如何永久移动布局吗?
如果您想查看全图,请参阅我的另一篇文章: https://stackoverflow.com/questions/14541265/changecursor-cause-layout-container-of-the-listview-to-reposition
theTranslationX.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator nullPointer) {
v.clearAnimation();
int theL = isMenuOn() ? 0 : v.getLeft() + getFilterWidth();
int theR = isMenuOn() ? v.getWidth() : v.getLeft() + getFilterWidth() + v.getWidth();
int theHeight = v.getHeight();
int theT = 0;
v.layout(theL, theT, theR, theHeight);
v.requestLayout();
}
});
【问题讨论】:
标签: android animation android-side-navigation