我正在開發一個小型Android項目。在狀態欄下方顯示工具欄時遇到一些問題。我使用以下配置:setfitsystemwindows not working windowtranslucentstatus coordinatorlayout
- 支持庫版本23.2.0
- windowTranslucentStatus =真
<CollapsingToolbarLayout fitSystemWindows="true" ...>
<FrameLayout fitSystemWindows="true" ...>
<ViewPager>
....consists a fragment with framelayout and image
</ViewPager>
<Toolbar fitSystemWindows="true" ...>
</FrameLayout>
<CollapsingToolbarLayout fitSystemWindows="true"...>
.....
</AppBarLayout>
</CoordinatorLayout>`
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/fragment_musicplayer_appBarlayout_test"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/fragment_musicexplorer_album_collapsingtoolbarlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="#eab22b"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_collapseMode="parallax"
android:fitsSystemWindows="true">
<android.support.v4.view.ViewPager
android:id="@+id/fragment_musicplayer_viewpager_test"
android:layout_width="match_parent"
android:layout_height="450dp" />
<android.support.v7.widget.Toolbar
android:id="@+id/fragment_musicplayer_toolbar_test"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@android:color/transparent"
android:fitsSystemWindows="true" />
</FrameLayout>
</android.support.design.widget.CollapsingToolbarLayout>
嗨,我要去嘗試一下。通常我認爲,我做的一切都是正確的,windowTranslucentStatus = true用於在statusbar後面顯示Viewpager-Fragment,fitSystemWindows = true在狀態欄 – Hans
@hata之後顯示工具欄,經過這麼多嘗試使Cordinator佈局能夠使用半透明狀態欄在KK上,似乎我們應該讓狀態欄像ICS和JB一樣黑暗,並且只讓21+ :(透明或半透明) –