启动界面黑屏解决

关于黑屏

默认的情况下,程序启动时,会有一个黑屏的时期,原因是,首个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.完成


参考代码:


  1. <style name="MyTheme.NoTitleBar.CustomBackground" parent="@android:Theme.Black">  
  2.         <item name="android:windowBackground">@drawable/loading</item>  
  3.         <item name="android:windowNoTitle">true</item>  
  4.         <item name="android:windowFullscreen">true</item>  
  5.         <item name="android:windowContentOverlay">@null</item>  
  6.  </style> 


  1. <application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true">         
  2.           <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">  
  3.           <intent-filter>  
  4.                        <action android:name="android.intent.action.MAIN">  
  5.                             <category android:name="android.intent.category.LAUNCHER">   </category>
  6.                       </action>
  7.          </intent-filter>  
  8.  </activity>  
  9. ...  
  10. ...
  11. </application>  

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值