Android--app启动 黑白屏问题 解决

app启动 黑白屏问题 


原因:

application 耗时较长

同时application 下设置了theme :android:Theme.Light.NoTitleBar android:Theme.Black.NoTitleBar





解决方法:

1、设置Style


//1、设置背景图Theme
<style name="Theme.AppStartLoad" parent="android:Theme">  
  <item name="android:windowBackground">@drawable/ipod_bg</item>  
  <item name="android:windowNoTitle">true</item>  
</style>

//2、设置透明Theme
<style name="Theme.AppStartLoadTranslucent" parent="android:Theme">  
  <item name="android:windowIsTranslucent">true</item> 
  <item name="android:windowNoTitle">true</item>  
</style>

上面我定义了两种Theme,第一种Theme就是设置一张背景图。当程序启动时,首先显示这张背景图,避免出现黑屏。第二种Theme是把样式设置为透明,程序启动后不会黑屏而是整个透明了,等到界面初始化完才一次性显示出来。下面说说两种方式的优缺点:

  • Theme1 程序启动快,界面先显示背景图,然后再刷新其他界面控件。给人刷新不同步感觉。
  • Theme2 给人程序启动慢感觉,界面一次性刷出来,刷新同步。

2、修改AndroidManifest.xml

为了使上面Theme生效,我们需要设置一些Activity的Theme

<application
  android:allowBackup="true"
  android:icon="@drawable/ipod_icon"
  android:label="@string/app_name"
  android:launchMode="singleTask">

<!-- iPod主界面 -->
	<activity
  		android:name="com.apical.apicalipod.IPodMainActivity"
  		 android:theme="@style/Theme.AppStartLoad"
 		 android:label="@string/app_name" >
  		<intent-filter>
 			 <action android:name="android.intent.action.MAIN" />
  			<category android:name="android.intent.category.LAUNCHER" />
 		 </intent-filter>
	</activity>

//......

</application>


















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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值