我有以下佈局:如何動畫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動畫內容的所有文檔,但我不想翻譯或縮放...我想爲佈局寬度屬性設置動畫效果。我找不到這樣的例子。
這樣做的正確方法是什麼?