Androidの授業 8 [ アニメーションクラス ]
【 簡易ピクチャビューワ 】
・前へボタンと次へボタンで画像が切り替わる
・res→drawable-hdpiフォルダに素材を入れておく
(ここでは arc apuos medias evo の4ファイルを使用)
※アニメーションしながら画像、文字処理をするクラスを使う
[ViewFlipper]
main.xmlを編集
----------------------------------
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android
"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ViewFlipper
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/flipper" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/arc" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/aquos" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/medias" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/evo" />
</ViewFlipper>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="前へ"
android:layout_weight="1" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="次へ"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
---------------------------------------------------
javaファイルの編集
----------------------------------
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android
"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ViewFlipper
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/flipper" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/arc" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/aquos" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/medias" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/evo" />
</ViewFlipper>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="前へ"
android:layout_weight="1" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="次へ"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
--------------------------------------------
※その他のアニメーション
参考
http://www.adamrocker.com/blog/181/android_animation.html