您现在的位置是:首页 > 文章详情

Android -- 使用主题配置文件,去掉程序启动界面的短暂黑屏

日期:2017-09-30点击:447

关于黑屏                                                                              

默认的情况下,程序启动时,会有一个黑屏的时期,原因是,首个activity会加载一些数据,比如初始化列表数据等.

去除步骤                                                                              

1./res/values/styles.xml 在 Theme 中,添加一个 android:windowBackgrounds 属性,设置需要的图片

2.在 AndroidManifest.xml 中设置Theme到首个启动的Activity下。

3.添加 /res/drawable-port/loading.png (若是横屏的启动画面,请放于 /res/drawable-land/loading.png )

4.完成

Code                                                                                   

复制代码
<style name="MyTheme.NoTitleBar.CustomBackground" parent="@android:Theme.Black"> <item name="android:windowBackground">@drawable/loading</item> <item name="android:windowNoTitle">true</item> <item name="android:windowFullscreen">true</item> <item name="android:windowContentOverlay">@null</item> </style>
复制代码
复制代码
<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true"> <activity android:label="@string/app_name" android:theme="@style/MyTheme.NoTitleBar.CustomBackground" android:configchanges="keyboardHidden|navigation|orientation" android:name="com.test.ui.MainActivity" android:screenorientation="portrait"> <intent-filter> <action android:name="android.intent.action.MAIN"> <category android:name="android.intent.category.LAUNCHER"> </category> </action> </intent-filter> </activity> ... ... </application>
复制代码

我是天王盖地虎的分割线                                                             

 

 




本文转自我爱物联网博客园博客,原文链接:http://www.cnblogs.com/yydcdut/p/3943385.html,如需转载请自行联系原作者

原文链接:https://yq.aliyun.com/articles/361835
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章