2
我試圖在kitkat
具有以下FrameLayout
實現Translucent StatusBar
,它的工作沒有CoordinatorLayout
這樣的:半透明狀態欄上的FrameLayout工具欄上面的奇巧和使用CoordinatorLayout
Layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:weightSum="1">
<FrameLayout
android:id="@+id/statusbar"
android:layout_width="match_parent"
android:layout_height="25dp"
android:background="@color/colorPrimaryDark" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:background="@color/colorPrimary" />
</LinearLayout>
而這條線在Styles.xml-v19
當然是:
<item name="android:windowTranslucentStatus">true</item>
,當然還有在onCreate
:
if (Build.VERSION.SDK_INT < 19) {
FrameLayout statusbar = (FrameLayout) findViewById(R.id.statusbar);
statusbar.setVisibility(View.GONE);
}
和起作用的:
但是,我不知道怎樣才能實現與CoordinatorLayout
和AppbarLayout
?
這是我嘗試的方式:
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/toolbarCollapse"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<FrameLayout
android:id="@+id/statusbar"
android:layout_width="match_parent"
android:layout_height="25dp"
android:background="?attr/colorPrimaryDark" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbarmain"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/ColorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/ToolbarStylepopuptheme"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
</android.support.design.widget.CollapsingToolbarLayout>
<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:tabIndicatorColor="@android:color/white"
app:tabIndicatorHeight="2dp"
app:tabMode="scrollable" />
</android.support.design.widget.AppBarLayout>
,並沒有工作。
更新:另外這個人是不工作:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 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/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".ui.MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:id="@+id/statusBar"
android:layout_width="match_parent"
android:layout_height="25dp"
android:background="@color/colorPrimaryDark"
android:translationZ="8dp" />
<android.support.design.widget.CoordinatorLayout
android:id="@+id/root_coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.NestedScrollView
android:id="@+id/nestedscrollview"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
...
...
任何解決方案來實現這一目標?
另外,讓我們來提一下,當我使用CoordinatorLayout
(相同條件)時,我遇到了與SystemBarTint相同的問題。我想不出他們怎麼能做到這一點。
此外,這裏有一個很好的教程,https://youtu.be/YCThIedqbCQ,但它不適合我。
總結這裏面'FrameLayout',所以狀態欄'FrameLayout'沾到它下面的頂部和一切幻燈片。 –
這完全忽略了適合系統Windows的點...但考慮它是多麼的破碎,我不會責怪任何人使用這種解決方法。 –
@ Su-AuHwang - 那麼,你有什麼建議? – Mohsen