Chinaunix
标题:
Android避免启动时闪一下黑屏
[打印本页]
作者:
baopbird2005
时间:
2015-09-22 14:00
标题:
Android避免启动时闪一下黑屏
1.设定主题,此主题为透明的,加入到res/values/styles.xml中:
<style name="Theme.AppStartLoadTranslucent" parent="android:Theme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowNoTitle">true</item>
</style>
复制代码
或者
<style name="app_splash" parent="android:Theme">
<item name="android:windowBackground">@drawable/splash_default</item>
<item name="android:windowNoTitle">true</item>
</style>
复制代码
2.设定android启动时使用此主题,在AndroidManifest.xml中设定:
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.AppStartLoadTranslucent"
>
<activity android:name=".MainActivity" 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>
复制代码
或者
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/app_splash"
>
<activity android:name=".MainActivity" 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>
复制代码
第一种方法是让activity变成透明的
第二种 方法是增加一个背景图片
作者:
baopbird2005
时间:
2015-09-22 14:01
我在项目中使用了第二种方式 但是不是所有的机型都能够实现这个功能
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2