Android 编程日记 解决应用启动时白屏或者黑屏的问题

来源:互联网 发布:2016淘宝可以刷单吗 编辑:程序博客网 时间:2024/04/30 13:58

解决应用启动时白屏或者黑屏的问题
由于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>

0 0
原创粉丝点击