反正以编程动画线性布局的布局重量财产 [英] Anyway to programmatically animate layout weight property of linear layout
问题描述
我有一个线性布局两种观点,我以编程方式改变自己的layout_weight财产。有没有一种方法,我可以在动画重量这种变化,所以当重量迈向一个新的大小改变看法幻灯片?
I have two views in a linear layout, I programmatically change their layout_weight property. Is there a way I could animate this change in weight so when the weight is changed views slides towards a new size?
推荐答案
我一直在寻找这一点。最后,我通过动画的父母,如果你有一个的LinearLayout两个视图其中工程非常漂亮的weightsum财产解决它。
I have been looking at this as well. Eventually I solved it by animating the weightsum property of the parent, which works very nice if you have two views in a LinearLayout.
请参阅:
<一href=\"http://stackoverflow.com/questions/8341745/animating-weightsum-property-using-objectanimator\">Animating使用ObjectAnimator weightSum财产
see: Animating weightSum property using ObjectAnimator
在下面的例子中,如果动画weightSum从1.0到2.0,屏幕2将很好地动画进入视野。
In the example below, if you animate the weightSum from 1.0 to 2.0, Screen 2 will animate nicely into view.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/dual_pane"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:weightSum="1.0">
<!-- Screen 1 -->
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="#ff0000"
android:layout_weight="1">
</LinearLayout>
<!-- Screen 2 -->
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="#ff6600"
android:layout_weight="1">
</LinearLayout>
</LinearLayout>
这篇关于反正以编程动画线性布局的布局重量财产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!