styles
<style name="ImageTranslucentTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!--在Android 4.4之前的版本上运行,直接跟随系统主题-->
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>styles-v19
<style name="ImageTranslucentTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">false</item>
</style>styles-v21
<style name="ImageTranslucentTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">false</item>
<!--Android 5.x开始需要把颜色设置透明,否则导航栏会呈现系统默认的浅灰色-->
<item name="android:statusBarColor">@android:color/transparent</item>
</style>设置app theme:
<application
android:name=".utils.MyApplication"
android:allowBackup="true"
android:icon="@mipmap/icon"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/ImageTranslucentTheme">
本文介绍了一种在不同Android版本中实现透明状态栏的方法。通过定义不同的样式文件以适应从Android 4.4到5.x及更高版本的变化,确保应用程序在不同时期的设备上都能呈现出一致的视觉效果。
632

被折叠的 条评论
为什么被折叠?



