啓動activity時,有個一閃而過界面

進入應用時,由於應用的啓動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)之前;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章