0

私はAndroidに少し慣れていませんが、VB.netにはかなり流暢です。スプラッシュスクリーンに関して2つの質問があります。

  1. アプリケーションの起動時に起動するスプラッシュ画面を作成しようとしています。Frame-Animationsでそれを行うことができますが、使用したい効果(fadeIn)があるため、TransitionDrawableクラスを使用したいと思います。定義を変更した後、Frame-Animationに同じコードを使用しましたが、機能させることができません。私は何が間違っているのですか?

  2. 私がロードしているこのロゴは16枚の画像で構成されています。TransitionDrawableクラスを使用して、logo1からlogo2、logo3 ...、logo16に移動するにはどうすればよいですか?ループと「imageIds」の配列を使用して独自のフレームアニメーションを作成しようとしましたが、トランジションでは機能しません。助けていただければ幸いです。

これが私のコードです:

public class SplashScreenActivity extends Activity {

    TransitionDrawable animation;
    ImageView transImage;

    Integer[] imageIds = { R.drawable.logo1, R.drawable.logo2,
            R.drawable.logo3, R.drawable.logo4, R.drawable.logo5,
            R.drawable.logo6, R.drawable.logo7, R.drawable.logo8,
            R.drawable.logo9, R.drawable.logo10, R.drawable.logo11,
            R.drawable.logo12, R.drawable.logo13, R.drawable.logo14,
            R.drawable.logo15, R.drawable.logo16 };

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splash);
        transImage = (ImageView) findViewById(R.id.splashImageView);
        animation = (TransitionDrawable) getResources().getDrawable(R.anim.transition_list);    
        transImage.setBackgroundDrawable(animation);        

        transImage.setOnTouchListener(new OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (event.getAction() == MotionEvent.ACTION_DOWN) {
                    finish();
                    startActivity(new Intent("com.V1.V1LogoSplash.V1LogoMainActivity"));
                }
                return false;
            }; // END ONTOUCH
        }); // END ONLISTSENER
    }



    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
        // TODO Auto-generated method stub
        super.onWindowFocusChanged(hasFocus);
        animation.startTransition(3000);
                  finish();
    }

}
4

1 に答える 1

0

このタイプのコードを試してください

public class SplashActivity extends Activity {

    Thread mSplashThread;

    private int SPLASH_DISPLAY_LENGTH = 3800;

    ImageView image;
    AnimationDrawable frameAnimation;

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

//      this.requestWindowFeature(Window.FEATURE_NO_TITLE);
//      this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
//              WindowManager.LayoutParams.FLAG_FULLSCREEN);

        setContentView(R.layout.splashactivity);

        image = (ImageView) findViewById(R.id.splashImg);

        image.setBackgroundResource(R.drawable.splash_animation);

        frameAnimation = (AnimationDrawable) image.getBackground();

        Thread splashTread = new Thread() {
            public void run() {
                try {
                    sleep(SPLASH_DISPLAY_LENGTH);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                } finally {
                    Intent intent;
                    intent = new Intent(SplashActivity.this,
                            ProductListActivity.class);
                    startActivity(intent);
                    finish();
                }
            }
        };
        splashTread.start();
    }

    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
        super.onWindowFocusChanged(hasFocus);
        frameAnimation.start();

    }

}

およびxmlで描画可能な他の1つ(xmlに配置されたimg)

<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
    android:oneshot="true" >

    <item
        android:drawable="@drawable/survey11"
        android:duration="500"/>

    <item
        android:drawable="@drawable/survey6"
        android:duration="300"/>
    <item
        android:drawable="@drawable/survey5"
        android:duration="300"/>

    <item
        android:drawable="@drawable/survey3"
        android:duration="300"/>
    <item
        android:drawable="@drawable/survey2"
        android:duration="300"/>
    <item
        android:drawable="@drawable/survey1"
        android:duration="800"/>



</animation-list>
于 2012-05-16T06:39:24.523 に答える