如何摆脱这个默认的启动画面?
How to get rid of this default splash screen?
我已经尝试将启动画面添加到我的应用程序中,虽然它们确实在主画面之前显示 activity,但无论如何此画面也始终显示:
这是 MainActivity 的代码:
public class MainActivity extends Activity implements WelcomeFragment.StartQuestions, QuestionFragment.QuestionsAnswered {
@Override
protected void onCreate(Bundle savedInstanceState) {
Parse.enableLocalDatastore(this);
Parse.initialize(this, "***************************", "*****************************");
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
loadingIcon = (ProgressBar) findViewById(R.id.loadingIcon);
loadingIcon.setVisibility(View.GONE);
checkInternetConnection();
showWelcomeScreen();
}
}
showWelcomeScreen():
public void showWelcomeScreen(){
Fragment fragment = getFragmentManager().findFragmentById(R.id.fragmentContainer);
if (fragment == null){
fragment = new WelcomeFragment();
getFragmentManager().beginTransaction()
.add(R.id.fragmentContainer, fragment)
.commit();
} else {
fragment = new WelcomeFragment();
getFragmentManager().beginTransaction()
.replace(R.id.fragmentContainer, fragment)
.commit();
}
}
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fragmentContainer"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/loadingPanel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
>
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true" android:id="@+id/loadingIcon"/>
</RelativeLayout>
在MainActivity中,我已经指定了去除顶栏:
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
应用本身没有这个栏。我在清单中默认放置的任何 activity(作为启动画面)仍然会在应用程序启动时继续显示上面显示的屏幕。
你不能。 Android 将 总是 尝试在 Activity 实际加载之前仅使用主题的属性来显示内容。
事实上,correct way to build a splash screen 涉及利用这一事实并自定义您的主题,以便在这段时间 显示的是 您的初始屏幕。
我已经尝试将启动画面添加到我的应用程序中,虽然它们确实在主画面之前显示 activity,但无论如何此画面也始终显示:
这是 MainActivity 的代码:
public class MainActivity extends Activity implements WelcomeFragment.StartQuestions, QuestionFragment.QuestionsAnswered {
@Override
protected void onCreate(Bundle savedInstanceState) {
Parse.enableLocalDatastore(this);
Parse.initialize(this, "***************************", "*****************************");
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
loadingIcon = (ProgressBar) findViewById(R.id.loadingIcon);
loadingIcon.setVisibility(View.GONE);
checkInternetConnection();
showWelcomeScreen();
}
}
showWelcomeScreen():
public void showWelcomeScreen(){
Fragment fragment = getFragmentManager().findFragmentById(R.id.fragmentContainer);
if (fragment == null){
fragment = new WelcomeFragment();
getFragmentManager().beginTransaction()
.add(R.id.fragmentContainer, fragment)
.commit();
} else {
fragment = new WelcomeFragment();
getFragmentManager().beginTransaction()
.replace(R.id.fragmentContainer, fragment)
.commit();
}
}
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fragmentContainer"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/loadingPanel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
>
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true" android:id="@+id/loadingIcon"/>
</RelativeLayout>
在MainActivity中,我已经指定了去除顶栏:
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
应用本身没有这个栏。我在清单中默认放置的任何 activity(作为启动画面)仍然会在应用程序启动时继续显示上面显示的屏幕。
你不能。 Android 将 总是 尝试在 Activity 实际加载之前仅使用主题的属性来显示内容。
事实上,correct way to build a splash screen 涉及利用这一事实并自定义您的主题,以便在这段时间 显示的是 您的初始屏幕。