Here is my code:
public class SplashScreen extends Activity {
private ImageView poweredByImage;
public 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.splash);
poweredByImage = (ImageView)findViewById(R.id.ImageView);
poweredByImage.setImageResource(R.drawable.powered_by);
this.handleAnimation(poweredByImage);
Handler handler = null;
handler = new Handler();
handler.postDelayed(new Runnable(){
public void run(){
Intent intent = new Intent(SplashScreen.this, HomeScreen.class);
startActivity(intent);
}
}, 3000);
}
public void handleAnimation(View v) {
v.startAnimation(AnimationUtils.loadAnimation(this, R.anim.fadein));
}
}
I navigate from one screen (SplashScreen) to another (HomeScreen), 开发者_如何学运维3 seconds after the first one appears, but before that to happen I want to start the fade-in animation 1 second after it appears and then the transition to new screen to happen.
So how can I do it? What should I use? Any help will be useful!
Why don't you use your handler to post a Runnable responsible of starting the animation after 1000ms? You then post your second Runnable that start your HomeScreen activity after 3000ms like you are actually doing.
精彩评论