Android:启动页有短暂白屏的解决方法
16lz
2021-01-23
Android:启动页有短暂白屏的解决方法
导致原因
theme用的是Theme.AppCompat.Light.NoActionBar:
<application android:name=".application.MyApplication" android:allowBackup="true" android:icon="@drawable/logo" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/Theme.AppCompat.Light.NoActionBar" tools:replace="icon, label, theme">
解决办法
添加一个新的style:
<activity android:name=".activity.SplashActivity" android:screenOrientation="portrait" android:theme="@style/styleSplash"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>
style中windowIsTranslucent属性设置为true,背景透明:
<style name="styleSplash" parent="Theme.AppCompat.Light.NoActionBar"> <item name="android:windowIsTranslucent">true</item> <item name="android:windowNoTitle">true</item> </style>
更多相关文章
- android > 设置button 背景颜色
- 修改dialog背景以及代码扩展AlertDialog和tint的使用
- android 之 布局属性--RelativeLayout
- android动态给view设置可见、不可见属性
- Android 动态设置布局属性