私は次のようなAndroidのテーブルレイアウトを持っています:
1) Row == IMAGEVIEW | TEXTVIEW
2) Row == IMAGEVIEW | SPINNER
次に、TEXTVIEW/SPINNER を切り替える必要があります。2列目は1列目、1列目は2列目です。
少しアニメーションもあれば最高です。Viewswitcher と Viewflipper を見てきましたが、これは私が探しているものではないようです。これを機能させる方法を知っている人はいますか?
私のレイアウト(その一部)は次のようになります。
<TableRow>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/left_layout_controlls"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:stretchColumns="*"
android:id="@+id/top_controlls"
android:layout_height="wrap_content">
<TableRow>
<ImageView
android:id="@+id/fromCountry_img"
android:src="@drawable/tc_rt_from"
android:layout_width="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_height="fill_parent"
/>
<TextView
android:id="@+id/fromCountry"
android:layout_marginTop="2px"
android:layout_marginLeft="2px"
android:background="@drawable/round_edges_main_controll"
android:layout_marginRight="2px"
android:layout_height="38px"
android:layout_width="160dip"/>
</TableRow>
</TableLayout>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:stretchColumns="*"
android:layout_below="@id/top_controlls"
android:layout_height="wrap_content">
<TableRow>
<ImageView
android:src="@drawable/tc_rt_to"
android:layout_width="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_height="fill_parent"
android:layout_below="@id/fromCountry_img"
/>
<Spinner
android:id="@+id/toCountry"
android:layout_height="wrap_content"
android:layout_marginTop="2px"
android:layout_marginBottom="2px"
android:layout_marginRight="2px"
android:layout_width="160dip"
android:layout_weight="1"
android:drawSelectorOnTop="true"/>
</TableRow>
</TableLayout>
アップデート:
このようにコントロールを切り替えようとしましたが、アニメーションは機能しますが、アニメーションが終了すると、コントロールは元の位置に戻ります。
理由はありますか?
LinearLayout layout1 = ((LinearLayout) DataHolder.activityHolder.findViewById(R.id.top_controll));
LinearLayout layout2 = ((LinearLayout) DataHolder.activityHolder.findViewById(R.id.bottom_controll));
DataHolder.activityHolder.findViewById(R.id.toCountry));
TranslateAnimation a = new TranslateAnimation(
Animation.ABSOLUTE,0,Animation.ABSOLUTE,0,
Animation.ABSOLUTE,0,Animation.ABSOLUTE, 40);
a.setDuration(1200);
TranslateAnimation b = new TranslateAnimation(
Animation.ABSOLUTE,0,Animation.ABSOLUTE,0,
Animation.ABSOLUTE,0,Animation.ABSOLUTE, -40);
b.setDuration(1200);
layout1.startAnimation(a);
layout2.startAnimation(b);