我一直在尋找通過這個問題和答案,但沒有發現任何有幫助。我有13 png。圖像,我試圖在我的啓動畫面中一個接一個地運行。以下是我正在使用的代碼。需要一個教程或幫助按框架啓動畫面?
splash.xml
<ImageView
android:contentDescription="@string/desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/logo"
android:background="@drawable/logo" />
splash.java
public class Splash extends Activity{
Animation animation;
MediaPlayer ourSong;
@Override
public void onAttachedToWindow() {
// TODO Auto-generated method stub
super.onAttachedToWindow();
Window window = getWindow();
window.setFormat(PixelFormat.RGBA_8888);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
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(7000);
} catch (InterruptedException e){
e.printStackTrace();
}finally{
Intent openStartingPoint = new Intent("com.thegoodwarren.lonte.STARTINGPOINT");
startActivity(openStartingPoint);
}
}
};
timer.start();
StartAnimations();
}
private void StartAnimations() {
// TODO Auto-generated method stub
Animation anim = AnimationUtils.loadAnimation(this, R.anim.alpha);
anim.reset();
LinearLayout l=(LinearLayout) findViewById(R.id.lin_lay);
l.clearAnimation();
l.startAnimation(anim);
anim = AnimationUtils.loadAnimation(this, R.anim.translate);
anim.reset();
ImageView iv = (ImageView) findViewById(R.id.logo);
iv.clearAnimation();
iv.startAnimation(anim);
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
ourSong.release();
finish();
}
}
爲用戶提供幫助,並且不要在您的應用中添加啓動畫面。 http://android.cyrilmottier.com/?p=632 – Simon 2013-02-22 22:00:56
這段代碼目前做了什麼,你想做什麼?你會專門縮小你的問題嗎? – halfer 2013-02-22 22:04:25
嗨Halfer,目前的代碼(閃屏)打開到PNG背景和聲音文件。但是,我希望它可以打開大約12個PNG文件(一個接一個地),並給出一個動畫鏡頭的外觀。這似乎很簡單,但我無法讓它工作。任何幫助? – Warren0618 2013-02-22 23:35:42