我正在制作带有透明状态栏的浏览器应用。我曾尝试使用 android:windowTranslucentStatus ,但这会使我的状态栏显示为灰色。现在,我改用 android:windowDrawsSystemBarBackgrounds ,但无法在其下绘制视图。 这是一张图片,您可以看到它的外观:
我的布局如下:
<?xml version="1.0" encoding="utf-8"?>
<com.mxn.soul.flowingdrawer_core.FlowingDrawer
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/transparent"
android:fitsSystemWindows="true"
app:edMenuSize="260dp"
app:edPosition="1">
<RelativeLayout
android:fitsSystemWindows="false"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/rootRR"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/statusBar"
android:focusable="true"
android:focusableInTouchMode="true">
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swipeToRefresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/webRoot"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:focusable="true">
<LinearLayout
android:id="@+id/shader"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/night_shader"
android:elevation="7dp"
android:orientation="vertical"
android:visibility="gone" />
</RelativeLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<LinearLayout
android:id="@+id/about_page"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:elevation="82dp"
android:visibility="invisible">
<include layout="@layout/about_page" />
</LinearLayout>
<LinearLayout
android:id="@+id/toolbarLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="vertical">
<include layout="@layout/tablet_tab_switcher" />
<androidx.appcompat.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="visible"
app:contentInsetEnd="0dp"
app:contentInsetStart="0dp">
<include layout="@layout/bar" />
</androidx.appcompat.widget.Toolbar>
</LinearLayout>
<TextView
android:id="@+id/abc"
android:layout_width="wrap_content"
android:layout_height="1dp"
android:layout_alignParentEnd="true"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
tools:ignore="RelativeOverlap,SelectableText" />
</RelativeLayout>
<LinearLayout
android:id="@+id/statusBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:orientation="horizontal" />
<FrameLayout
android:id="@+id/customViewContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
android:visibility="invisible" />
<include layout="@layout/tab_switcher" />
</RelativeLayout>
<!--menu-->
<include android:fitsSystemWindows="true" layout="@layout/left_drawer_layout" />
<!--menu end-->
</com.mxn.soul.flowingdrawer_core.FlowingDrawer>