【原】android啟動時白屏或者黑屏的問題


解決應用啟動時白屏或者黑屏的問題
由於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>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM