白色背景时,Android应用程序启动 [英] White background when Android app start up
本文介绍了白色背景时,Android应用程序启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
每天,当我的应用程序启动时,有一个在很短的时间在白色背景显示。
尽管使用闪屏的,问题是依然存在。
我想启动屏幕设置为黑色而不是白色为默认!
这是我泼的屏幕活动:
公共类SplashActivity延伸活动{私有静态字符串标记= SplashActivity.class.getName();
私有静态长SLEEP_TIME = 1; //休眠一段时间@覆盖
保护无效的onCreate(捆绑savedInstanceState){
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE); //删除标题栏
的setContentView(R.layout.splash); //启动定时器并启动主要活动
IntentLauncher发射=新IntentLauncher();
launcher.start();
}私有类IntentLauncher继承Thread { / **
*睡眠一段时间,不是启动新的活动。
* /
@覆盖
公共无效的run(){
尝试{
//睡眠
视频下载(SLEEP_TIME * 1000);
}赶上(例外五){
Log.e(TAG,e.getMessage());
} //开始主要活动
意向意图=新意图(SplashActivity.this,MainActivity.class);
SplashActivity.this.startActivity(意向);
SplashActivity.this.finish();
}}@覆盖
保护无效的onPause(){
super.onPause();
overridePendingTransition(R.anim.fade_in,R.anim.fade_out);
}
}
解决方案
在您的清单中使用此标记:
安卓主题=@安卓风格/ Theme.NoTitleBar.Fullscreen
而不是:
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
Every when my app starts up, there's a white background displays in a short time. Despite of using splash screen, the problem is still exists. I would like to set the start up screen to black instead of white as default!
This is my splash's screen activity:
public class SplashActivity extends Activity {
private static String TAG = SplashActivity.class.getName();
private static long SLEEP_TIME = 1; // Sleep for some time
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE); // Removes title bar
setContentView(R.layout.splash);
// Start timer and launch main activity
IntentLauncher launcher = new IntentLauncher();
launcher.start();
}
private class IntentLauncher extends Thread {
/**
* Sleep for some time and than start new activity.
*/
@Override
public void run() {
try {
// Sleeping
Thread.sleep(SLEEP_TIME*1000);
} catch (Exception e) {
Log.e(TAG, e.getMessage());
}
// Start main activity
Intent intent = new Intent(SplashActivity.this, MainActivity.class);
SplashActivity.this.startActivity(intent);
SplashActivity.this.finish();
}
}
@Override
protected void onPause() {
super.onPause();
overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
}
}
解决方案
Use this tag in your manifest:
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
instead of :
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
这篇关于白色背景时,Android应用程序启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文