Layout resize animation
- by Marcin Sosna
I have layout:
<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>
When I set visibility to GONE on left and right fragment container then they are animated to left and right. I try to set scale animation on resize center graph_fragment_container, my code:
<scale android:fromXScale="100%" android:toXScale="50%"
android:fillAfter="true"
android:fillEnabled="true"
android:duration="7000" />
Java code:
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 );
Now graphContainer was resize after right and left layout animation end, and user see a grey backgound before center layout was resize.