当我启动模拟器时,动画只播放动画的第一帧,在计时器的持续时间内停留,然后开始活动。
这是我的Drawable xml
<?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/title1" android:duration="200" />
<item android:drawable="@drawable/title2" android:duration="200" />
<item android:drawable="@drawable/title3" android:duration="200" />
<item android:drawable="@drawable/title4" android:duration="200" />
<item android:drawable="@drawable/title5" android:duration="200" />
<item android:drawable="@drawable/title6" android:duration="200" />
<item android:drawable="@drawable/title7" android:duration="200" />
<item android:drawable="@drawable/title8" android:duration="200" />
<item android:drawable="@drawable/title9" android:duration="200" />
<item android:drawable="@drawable/title10" android:duration="200" />
<item android:drawable="@drawable/title11" android:duration="200" />
</animation-list>
这是我的布局xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
>
<ImageView
android:id="@+id/gyro"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true"
/>
这是我的java文件
public void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
// Start the animation (looped playback by default).
ImageView splash = (ImageView) findViewById(R.id.gyro);
splash.setBackgroundResource(R.drawable.title);
AnimationDrawable splashAnimation = (AnimationDrawable) splash.getBackground();
splashAnimation.start();
Thread logoTimer = new Thread(){
public void run(){
try{
int logoTimer = 0;
while(logoTimer <10000){
sleep(100);
logoTimer = logoTimer + 100;
}//end of while loop
//mpsplash.stop();
startActivity(new Intent("tv.bScienceFiction.scrip.or.scrap.CLEARSCREEN"));
} catch (InterruptedException e) {
//TODO Auto-generated catch block
e.printStackTrace();
}
finally{
finish();
}//end of finally
}//end of run
};//end of new Thread
logoTimer.start();
}
答案 0 :(得分:0)
在退出onCreate
splash.postDelayed(new Runnable() {
public void run() {
splashAnimation.start();
}
}, 200);