Android标题透明沉浸式UI

来源:互联网 发布:数据库实例 schema关系 编辑:程序博客网 时间:2024/05/19 16:34

透明状态栏加透明导航栏

透明标题

透明导航

style的配置

android从4.4开始,开始支持UI使用StatusBar与NavigationBar的范围。

所以要进行下面的配置:

在value中的styles.xml中设置

<!-- Base application theme. --><style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">    <!-- Customize your theme here. --></style><style name="AppTheme" parent="AppTheme.Base"></style>

在value-v19中的styles.xml中设置(为了兼容4.4)

<style name="AppTheme" parent="AppTheme.Base">    <item name="android:windowTranslucentStatus">true</item>    <item name="android:windowTranslucentNavigation">true</item></style>

在value-v21中的styles.xml中设置

<style name="AppTheme" parent="AppTheme.Base">    <!--透明状态栏-->    <item name="android:windowTranslucentStatus">true</item>    <!--透明导航栏-->    <item name="android:windowTranslucentNavigation">true</item>     <!--使状态栏,导航栏可绘制-->    <item name="android:windowDrawsSystemBarBackgrounds">true</item></style>

然后使用AppTheme这个主题,这是1个示例,应该看得出来吧。只要在你的AppTheme的v19版本和v21版本添加了相应属性就好。

1 0
原创粉丝点击