布局调整动画大小

时间:2012-06-19 09:13:15

标签: android animation layout resize

我有布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >

    <LinearLayout
            android:id="@+id/main_fragment_container" 
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">

        <RelativeLayout 
                android:id="@+id/left_fragments_layout"
                android:layout_width="0dip"
                android:layout_height="fill_parent"
                android:layout_weight="1"
                android:background="#00F"> 
        </RelativeLayout>     

        <RelativeLayout 
                android:id="@+id/graph_fragment_container"
                android:layout_width="0dip"
                android:layout_height="fill_parent"
                android:layout_weight="2.2"
                android:background="#666">          
        </RelativeLayout>    

        <RelativeLayout 
                android:id="@+id/right_fragments_layout"
                android:layout_width="0dip"
                android:layout_height="fill_parent"
                android:layout_weight="1"
                android:background="#00F">          
        </RelativeLayout>

    </LinearLayout>

</LinearLayout>

当我在左右碎片容器上设置GONE的可见性时,它们会被左右动画。我尝试在调整大小中心graph_fragment_container上设置缩放动画,我的代码:

<scale android:fromXScale="100%" android:toXScale="50%"
        android:fillAfter="true"
        android:fillEnabled="true"
        android:duration="7000" />

Java代码:

Animation toLeftOut = AnimationUtils.loadAnimation( MainActivity.this, R.anim.to_left_out );
Animation toRightOut = AnimationUtils.loadAnimation( MainActivity.this, R.anim.to_right_out );
Animation scale = AnimationUtils.loadAnimation( MainActivity.this, R.anim.scal );
graphContainer.startAnimation( scale );
leftFragmentsLayout.startAnimation( toLeftOut );
rightFragmentsLayout.startAnimation( toRightOut );

现在,在左右布局动画结束后,graphContainer被调整大小,用户在中心布局调整大小之前看到了灰色的背景。

0 个答案:

没有答案