我使用全屏大小的启动画面没有操作栏布局但是当我移动到具有操作栏的正常活动的登录活动时,我的布局不能顺利移动它显示一些闪烁(向上/向下)。我不是克服它请帮助...
我正在使用Intent将操作从splash活动传递到登录活动
这是我的启动画面代码:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
/* set time to splash out */
final int welcomeScreenDisplay = 4000;
/* create a thread to show splash up to splash time */
Thread welcomeThread = new Thread() {
int wait = 0;
@Override
public void run() {
try {
super.run();
/*
* use while to get the splash time. Use sleep() to increase
* the wait variable for every 100L.
*/
while (wait < welcomeScreenDisplay) {
sleep(100);
wait += 100;
}
} catch (Exception e) {
System.out.println("EXc=" + e);
} finally {
/*
* Called after splash times up. Do some action after splash
* times up. Here we moved to another main activity class
*/
startActivity(new Intent(SplashActivity.this,
LoginActivity.class));
finish();
}
}
};
welcomeThread.start();
}
}
答案 0 :(得分:0)
使用它来代替创建延迟
/** Duration of wait **/
private final int SPLASH_DISPLAY_LENGTH = 1000;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.splashscreen);
/* New Handler to start the Menu-Activity
* and close this Splash-Screen after some seconds.*/
new Handler().postDelayed(new Runnable(){
@Override
public void run() {
/* Create an Intent that will start the Menu-Activity. */
Intent mainIntent = new Intent(Splash.this,Menu.class);
Splash.this.startActivity(mainIntent);
Splash.this.finish();
}
}, SPLASH_DISPLAY_LENGTH);
}
答案 1 :(得分:0)
它解决了你的问题。
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
startActivity(new Intent(SplashActivity.this,LoginActivity.class));
// for activity animation.
//overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
finish();
答案 2 :(得分:0)
以
启动您的活动new Handler().postDelayed(new Runnable(){
@Override
public void run() {
/* Create an Intent that will start the Menu-Activity. */
Intent mainIntent = new Intent(Splash.this,Menu.class);
mainIntent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
Splash.this.startActivity(mainIntent);
Splash.this.overridePendingTransition(0,0);
Splash.this.finish();
}
}, SPLASH_DISPLAY_LENGTH);