我正在使用协调器布局隐藏工具栏但问题是在某些设备(android 4.4)在滚动列表时得到空白工具栏,请帮帮我
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize">
<android.support.v7.widget.Toolbar
android:id="@+id/n_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:theme="@style/ToolbarColoredBackArrow"
app:layout_scrollFlags="scroll|enterAlways"
android:minHeight="?attr/actionBarSize">
<ViewStub
android:id="@+id/toolbar_view_stub"
android:layout_width="match_parent"
android:background="@color/primary"
android:layout_height="match_parent" />
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<!--add your layout content here -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<View
style="@style/match_wrap"
android:layout_height="0.5dp"
android:background="@color/accent" />
<ViewStub
android:id="@+id/content_area"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</LinearLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_refine"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:visibility="gone"
android:layout_marginBottom="50dp"
android:layout_marginRight="50dp"
app:backgroundTint="@color/color_blue" />
</android.support.design.widget.CoordinatorLayout>
答案 0 :(得分:0)
试试这个......
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/primary"
android:minHeight="?attr/actionBarSize"
android:textAlignment="center"
local:popupTheme="@style/ThemeOverlay.AppCompat.Light"
local:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" >
<ViewStub
android:id="@+id/toolbar_view_stub"
android:layout_width="match_parent"
android:background="@color/primary"
android:layout_height="match_parent" />
</android.support.v7.widget.Toolbar>
愿它有所帮助!
答案 1 :(得分:0)
找到解决方案我必须在工具栏正下方添加一个空视图
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/n_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
app:theme="@style/ToolbarColoredBackArrow">
<ProgressBar
android:id="@+id/progressBar"
style="@style/wrap_wrap"
android:visibility="gone"
android:layout_gravity="end"
android:indeterminate="true"
android:padding="@dimen/defaultLayoutPadding" />
<ViewStub
android:id="@+id/toolbar_view_stub"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v7.widget.Toolbar>
<!-- The empty is used for fixing the empty blank header issue,please don't remove it -->
<View
android:layout_width="fill_parent"
android:layout_height="1dp" />
</android.support.design.widget.AppBarLayout>