如果我能夠與半透明導航欄是純色
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
然後在工具欄是狀態欄的後面(狀態欄應該是彩色的,但導航欄應該是半透明)的半透明導航欄。但是,如果我轉到此活動的佈局XML並放入android:fitsSystemWindows="true"
,工具欄已正確佈置,但導航欄則是純色。
這裏的佈局:
<?xml version="1.0" encoding="utf-8"?>
<me.ccrama.redditslide.Views.SidebarLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:background="?attr/activity_background">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:id="@+id/anchor"
android:layout_width="1dp"
android:layout_marginTop="4dp"
android:layout_marginRight="3dp"
android:layout_gravity="top|right"
android:layout_height="1dp" />
<me.ccrama.redditslide.Views.ToggleSwipeViewPager
android:id="@+id/content_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.AppBarLayout
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:minHeight="56dp"
android:layout_height="?android:attr/actionBarSize"
android:theme="@style/ActionBarCompat"
android:title="@string/app_name" />
<ViewStub
android:id="@+id/stub_tabs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inflatedId="@+id/sliding_tabs"
android:layout="@layout/activity_overview_tabs" />
</android.support.design.widget.AppBarLayout>
</FrameLayout>
<ListView
android:id="@+id/drawerlistview"
android:layout_width="300dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="?attr/card_background"
android:orientation="vertical" />
<include
layout="@layout/subinfo"
android:layout_width="300dp"
android:layout_height="match_parent"
android:layout_gravity="end" />
</me.ccrama.redditslide.Views.SidebarLayout>
同樣的行爲(彩色導航欄)發生,如果我把android:fitsSystemWindows="true"
的FrameLayout
,而不是內部。
下面的第一張圖片是當工具欄佈局混亂,第二部手機是導航欄不透明時。下面
getWindow()setStatusBarColor(Color.TRANSPARENT) ; –
但如果我爲狀態欄着色會怎麼樣?我已經將它設置爲紅色。 – Nxt3
你的意思是? –