消除 activity 启动时白屏、黑屏问题

来源:互联网 发布:apache 配置php报错 编辑:程序博客网 时间:2024/05/19 13:29

默认情况下 activity 启动的时候先把屏幕刷成白色,再绘制界面,绘制界面或多或少有点延迟,这段时间中你看到的就是白屏,显然影响用户体验,怎么消除呢?


在 Activity theme 设置style 即可


[html] view plaincopy
  1. <style name="AppTheme" parent="android:Theme.Light.NoTitleBar">  
  2.     <item name="android:windowIsTranslucent">true</item>  
  3.     <item name="android:windowNoTitle">true</item>  
  4.     <item name="android:windowActionBar">false</item>  
  5.     <item name="android:windowBackground">@android:color/transparent</item>  
  6.     <!-- All customizations that are NOT specific to a particular API-level can go here. -->  
  7. </style>  


[html] view plaincopy
  1. <application  
  2.         android:name="com.skymobi.moposns.MyApplication"  
  3.         android:allowBackup="true"  
  4.         android:icon="@drawable/ic_launcher"  
  5.         android:label="@string/app_name"  
  6.         android:theme="@style/AppTheme" >  
  7.         <activity  
  8.             android:name="com.skymobi.moposns.MainActivity"  
  9.             android:label="@string/app_name"  
  10.             android:screenOrientation="portrait" >  
  11.             <intent-filter>  
  12.                 <action android:name="android.intent.action.MAIN" />  
  13.   
  14.                 <category android:name="android.intent.category.LAUNCHER" />  
  15.             </intent-filter>  
  16.         </activity>  
  17. 转自http://blog.csdn.net/z1074971432/article/details/10533735
0 0
原创粉丝点击