Android沉浸式状态栏

来源:互联网 发布:高仿手表淘宝店 编辑:程序博客网 时间:2024/06/05 19:18
完成沉浸式其实网上有很多的办法

我这里面只提供一种但是我感觉这种方式很自由,

在styles里面

<!-- Base application theme. --><style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">    <!-- Customize your theme here. -->    <item name="colorPrimary">@color/colorBase</item>    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>    <item name="colorAccent">@color/colorAccent</item>    <item name="android:windowTranslucentStatus">true</item></style>

在styles里面设置 <item name="android:windowTranslucentStatus">true</item>

manifest

里面设置:

<application    android:allowBackup="true"    android:icon="@mipmap/ic_launcher"    android:label="@string/app_name"    android:supportsRtl="true"    android:theme="@style/AppTheme"    android:name=".MyApplication"    >

在每一个布局里面设置

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:orientation="vertical"    android:clipToPadding="false">

这样的话就可以实现全屏 状态栏被隐藏掉 但是状态栏里面的东西 像电量啊。。。这些都还存在,这样你自己可以做的东西就多了 可以任意定义就像你自己的布局一样


原创粉丝点击