android啓動時白屏或者黑屏的問題

來源:http://www.cnblogs.com/U-tansuo/archive/2013/03/27/U_tansuo-android.html


由於Activity只能到onResume時,才能展示到前臺,所以,如果爲MAIN activity設置背景的話,無論onCreate-onResume速度多快,都會出現短暫的白屏或者黑屏 
其實解決的辦法很簡單,只需將你的Startup Activity中的View的background屬性刪除(mainLayout.xml 中的background屬性刪除),
然後在AndroidManifest.xml爲你的Startup Activity加上theme屬性即可

1、theme的xml在res/values/styles.xml 下

<resources>

    <stylename="AppTheme"parent="android:Theme.Light">

    <itemname="android:windowBackground">@null</item>//@null黑屏  @drawable/icon放一張啓動圖片

    <itemname="android:windowNoTitle">true</item> //啓動界面是否顯示應用名稱 true不顯示 false顯示

</style>

 </resources>

2、AndroidManifest.xml裏面

   <activityandroid:name=".openframework"

                  android:label="@string/app_name"

                  android:screenOrientation="portrait"

                  android:theme= "@style/AppTheme" 

                  android:configChanges="orientation">

            <intent-filter>

                <actionandroid:name="android.intent.action.MAIN"/>

                <categoryandroid:name="android.intent.category.LAUNCHER"/>

            </intent-filter>

        </activity>


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