解決應用啟動時白屏或者黑屏的問題
由于Activity只能到onResume時,才能展示到前臺,所以,如果為MAIN activity設置背景的話,無論onCreate-onResume速度多快,都會出現短暫的白屏或者黑屏?
其實解決的辦法很簡單,只需將你的Startup Activity中的View的background屬性刪除(mainLayout.xml 中的background屬性刪除),
然后在AndroidManifest.xml為你的Startup Activity加上theme屬性即可
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>
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>