长话短说,最近做项目,想把启动页的图呈现出全屏的样式(状态栏暂时不显示),从网上找了很多攻略都不行,后来自己摸索出正确姿势,放在这里:
res/values/styles.xml
中:
<style name="splash" parent="@style/Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">@mipmap/launch_page</item>
<item name="android:windowFullscreen">true</item>
</style>
res/values-v21/styles.xml
中:
<style name="splash" parent="@style/Theme.AppCompat.Light.NoActionBar">
<item name="android:windowTranslucentStatus">false</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowBackground">@mipmap/launch_page</item>
</style>
然后在启动页的theme
中设置 android:theme="@style/splash"
:
<activity
android:name="com.xsyx.mixture.ui.activity.SplashActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:launchMode="standard"
android:screenOrientation="portrait"
android:theme="@style/splash">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>