0

AnimationDrawable を使用して Loading Animation を表示しようとしています。Visibility を VISIBLE に設定して、読み込み中の「画面」を可視にします。

画面が設定された後に AnimationDrawable を開始する必要があることを知っており、onWindowFocusChanged で Google Developers のソリューションを使用しました。

    @Override public void onWindowFocusChanged(boolean hasFocus) {
    // TODO Auto-generated method stub
        super.onWindowFocusChanged(hasFocus);ImageView img = (ImageView)findViewById(R.id.animationView);
    img.setBackgroundResource(R.drawable.animation_position);

    AnimationDrawable frameAnimation = (AnimationDrawable)img.getBackground();

    if (hasFocus){
            //normal Screen
    RelativeLayout listView = (RelativeLayout)findViewById(R.id.listAnzeige);
    listView.setVisibility(View.GONE);

    //Loading Screen
    RelativeLayout ladeScreen = (RelativeLayout)findViewById(R.id.Position);
    ladeScreen.setVisibility(View.VISIBLE);


    frameAnimation.start();

私の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/f1" android:duration="100" />
<item android:drawable="@drawable/f2" android:duration="100" />
<item android:drawable="@drawable/f3" android:duration="100" />
<item android:drawable="@drawable/f4" android:duration="100" />
<item android:drawable="@drawable/f5" android:duration="100" />
<item android:drawable="@drawable/f6" android:duration="100" /></animation-list>    

アニメーションが開始されません。問題は可視性だと思いますが、よくわかりません。手伝ってくれてありがとう。

4

0 に答える 0