ワーキンググループ/勉強会?
Androidでは、pngフォーマットなどのイメージファイルをImageViewで表示することができます。
また、テキストビューや、イメージビューなどを、XMLで記述したアニメーションリソースにしたがって動作させることができます。
#ref(): File not found: "anim.001.project.jpg" at page "勉強会/HelloAnimetion"
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <ImageView android:id="@+id/image_view" android:layout_centerInParent="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/handson" /> </RelativeLayout>
<?xml version="1.0" encoding="UTF-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:fillBefore="true" android:fillAfter="true" > <translate android:interpolator="@android:anim/accelerate_interpolator" android:fromXDelta="-100" android:toXDelta="100" android:fromYDelta="-100" android:toYDelta="100" android:duration="6000" android:fillBefore="false" android:fillAfter="true" /> <rotate android:fromDegrees="0" android:toDegrees="180" android:toYScale="0.0" android:pivotX="50%" android:pivotY="50%" android:startOffset="700" android:duration="400" android:fillBefore="false" android:fillAfter="true" /> </set>
// アニメーションするイメージを取得 ImageView animWindow = (ImageView)findViewById(R.id.image_view); // アニメーションリソースをロード Animation anim = AnimationUtils.loadAnimation(this, R.anim.move); anim.setRepeatMode(Animation.RESTART); // アニメーション開始 animWindow.startAnimation(anim);
package jp.hews.helloanim; import android.app.Activity; import android.os.Bundle; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.widget.ImageView; public class HelloAnimetionActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // アニメーションするイメージを取得 ImageView animWindow = (ImageView)findViewById(R.id.image_view); // アニメーションリソースをロード Animation anim = AnimationUtils.loadAnimation(this, R.anim.move); anim.setRepeatMode(Animation.RESTART); // アニメーション開始 animWindow.startAnimation(anim); } }