1

だから私はいくつかのアニメーション ImageViews で説明したように作成したい:

http://developer.android.com/reference/android/graphics/drawable/AnimationDrawable.html

しかし、私は検索してきましたが、この件については何も見つかりませんでした。アニメーションリストの項目を拡張 APK ファイル (zip ファイル) 内の画像にすることはできますか? 拡張 APK ファイルから画像を取得する方法は既に知っていますが、プログラムによって、または XML ファイルで何らかの形で参照されて、どうにかしてアニメーション リストに画像を取得できるかどうかを知りたいです。

私の質問は、これが可能かどうかです。そして(可能であれば)どうすればこれを行うことができますか?

4

1 に答える 1

0

アニメーション効果のために first.png、second.png などの名前の描画可能なフォルダーに置かれた画像の別のフレームを使用し、一定の時間後にそれをロードすることができます。

animation_list.xmlを作成して配置します。

<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
    android:oneshot="false">
    <item android:drawable="@drawable/first" android:duration="210" />
    <item android:drawable="@drawable/second" android:duration="210" />
    <item android:drawable="@drawable/third" android:duration="210" />
    <item android:drawable="@drawable/fourth" android:duration="210" />
    <item android:drawable="@drawable/fifth" android:duration="210" />
    <item android:drawable="@drawable/sixth" android:duration="210" />

</animation-list>

次に、MainActivity コード is.create imageview で、activity_main xml に yourImageView という名前を付けます。

import android.os.Bundle;
import android.app.Activity;
import android.graphics.drawable.AnimationDrawable;
import android.widget.ImageView;

public class MainActivity extends Activity {

    private AnimationDrawable frameAnimation;
    private ImageView view;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

        // Type casting the Image View
        view = (ImageView) findViewById(R.id.yourImageView);

        // Setting animation_list.xml as the background of the image view
        view.setBackgroundResource(R.drawable.animation_list);

        // Type casting the Animation drawable
        frameAnimation = (AnimationDrawable) view.getBackground();
        frameAnimation.start();
    }
}
于 2014-12-19T06:00:49.987 に答える