我有以下布局:如何动画ViewGroups的布局属性?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent">
<FrameLayout android:id="@+id/viewgroup_left"
android:layout_height="match_parent"
android:layout_weight="2"
android:layout_width="0dp">
... children ...
</FrameLayout>
<LinearLayout android:id="@+id/viewgroup_right"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_width="0dp"
android:orientation="vertical">
... children ...
</LinearLayout>
</LinearLayout>
我结束了这样的事情:
+------------------------+------------+
| | |
| | |
| Left | Right |
| | |
| | |
+------------------------+------------+
当某个切换被触发,我想动画左,使得其宽度扩大,以填补整个屏幕。同时,我想动画Right的宽度,使其缩小到零。之后,当切换再次切换时,我需要将事物恢复到上述状态。
我试着写我自己的动画,调用View.getWidth()
,但当我动画回到该值(通过设置View.getLayoutParams().width
)它比它开始时更宽。我怀疑我只是做错了。我也阅读了Honeycomb动画内容的所有文档,但我不想翻译或缩放...我想为布局宽度属性设置动画效果。我找不到这样的例子。
这样做的正确方法是什么?