-1

スプラッシュ スクリーンに 2 つの画像が読み込まれています。最初の画像が開き (スプラッシュ スクリーンを開始)、2 番目の画像が開きます。2 番目の画像がフェードアウトすると、MainActivity が開始されます。ここで私の質問は、最初の画像をフェードアウトさせてから、2 番目の画像でフェードインさせる方法です。

私はどちらかの間でフェードをクロスしようとはしていません。私は完全にフェードアウトしてからフェードイントランジションを実行しようとしています。

スプラッシュ.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_gravity="center"
    android:id="@+id/lin_lay"
    android:gravity="center" >

    <ImageView
        android:contentDescription="@string/desc"
        android:orientation="horizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/spinning_wheel_image"
        android:background="@drawable/splashscreen1" />

</LinearLayout>

mainanim.xml

<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false">
    <item android:drawable="@drawable/splashscreen1" android:duration="2500" />
    <item android:drawable="@drawable/splashscreen2" android:duration="4000" />
</animation-list>

Splash.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splash);
    ourSong = MediaPlayer.create(Splash.this, R.raw.splashsound);
    ourSong.start();
    Thread timer = new Thread(){
        public void run(){
            try{
                sleep(10500);
            } catch (InterruptedException e){
                e.printStackTrace();
            }finally{
                Intent openStartingPoint = new Intent("com.theapplication.app.STARTINGPOINT");
                startActivity(openStartingPoint);

            }
        }
    };
    timer.start();
}

@Override
public void setRequestedOrientation(int requestedOrientation) {
    super.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}

@Override
public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);
    ImageView mainimage = (ImageView)findViewById(R.id.spinning_wheel_image);
    mainimage.setBackgroundResource(R.anim.mainamin);
    mainanimation = (AnimationDrawable) mainimage.getBackground();
    mainanimation.start();
}
4

1 に答える 1

0

このデモを試すことができます。

あなたに役立つかもしれません。

于 2013-03-12T05:52:53.890 に答える