需要教程或帮助制作逐帧闪屏?

时间:2013-02-22 21:55:04

标签: java android xml splash-screen

我一直在寻找问题和答案,但没有找到任何帮助。我有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();
}

}

1 个答案:

答案 0 :(得分:0)

  

我有13 png。我试图在我的启动画面中一个接一个地运行的图像。

创建AnimationDrawable in the form of an <animation-list> drawable resource。列出每个PNG以及应该在XML中在该帧上花费的时间。在AnimationDrawable中使用ImageView,并在其上调用startAnimation()即可开始设置动画。