進入應用時,由於應用的啓動Activity都會有默認的theme,所以會跳一下原始界面,才啓動我們定義的theme。
修改這個問題的方法,就是給應用啓動的Activity設置一個空的theme。如下面的例子:
聯繫人啓動時的Activity爲PeopleActivity ,我們就在manifest文件中設置PeopleActivity 的theme爲一個空的theme
<activity android:name=".activities.PeopleActivity"
android:label="@string/people"
android:theme="@style/GnEmptyTheme"
android:uiOptions="splitActionBarWhenNarrow"
android:clearTaskOnLaunch="true"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustPan"
android:configChanges="orientation"
>
GnEmptyTheme 就是一個空的theme,裏面什麼內容頁沒有,在styles.xml中如下定義:
<style name="GnEmptyTheme">
</style>
要實現白色主題、黑色主題或者透明主題,就在此Activity的onCreate方法中,使用setTheme設置對應主題即可。
注意setTheme要在super.onCreate(savedInstanceState)之前;