当您启动 android 应用程序时,主要活动以白色背景和黑色标题开始,您的应用程序名称位于左角。像这样
如何完全删除这个(当应用程序启动时不显示这个)并在屏幕上添加自定义加载进度条或一些标志?
当您启动 android 应用程序时,主要活动以白色背景和黑色标题开始,您的应用程序名称位于左角。像这样
如何完全删除这个(当应用程序启动时不显示这个)并在屏幕上添加自定义加载进度条或一些标志?
How about creating a splash dialog with custom layout containing progress bar?
In your main activity do something like this
private SplashDialog mSplashDialog;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
showSplashScreen();
setContentView(R.layout.yourmainlayout);
}
protected void removeSplashScreen() {
if (mSplashDialog != null) {
mSplashDialog.dismiss();
mSplashDialog = null;
}
}
protected void showSplashScreen() {
mSplashDialog = new SplashDialog(this, R.style.splash_dialog);
mSplashDialog.setCancelable(false);
mSplashDialog.show();
}
Create custom dialog
public class SplashDialog extends Dialog {
private ProgressBar mProgressBar;
public SplashDialog(Context context, int theme) {
super(context, theme);
setContentView(R.layout.splash_dialog);
mProgressBar = (ProgressBar) findViewById(R.id.splash_progress);
}
public void setProgress(int progress) {
mProgressBar.setProgress(progress);
}
}
And add style to that will let dialog fill all screen.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="splash_dialog">
<item name="android:padding">0dp</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowFrame">@null</item>
</style>
</resources>
To change dialog's progress value call mSplashDialog.setProgress(int progress)
.
When your data is loaded call removeSplashScreen()
.
对我有用的(因为我在开始时没有太多负载,实际上我根本不需要启动画面)正在更改 res/values/styles.xml :
<resources>
<color name="custom_theme_color">#000000</color>
<style name="AppTheme" parent="android:Theme.Light" >
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@color/custom_theme_color</item>
</style>
</resources>
它只是从黑屏开始,当它全部加载时进入全屏(1-2 秒后)。看起来很“专业”。
我想你要找的可以在这里找到: