,我滾動list.For更多信息我正在分享我的代碼時,我無法隱藏工具欄下面給出:隱藏工具欄滾動時recyclerview
1.Common佈局應用
<?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"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/background_light">
<RelativeLayout
android:id="@+id/main_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- <include layout="@layout/custom_toolbar" />-->
<RelativeLayout
android:id="@+id/toolbarContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="@+id/customToolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:textColorPrimary="@color/textColorPrimary"
app:colorButtonNormal="@android:color/white"
app:colorControlHighlight="?attr/colorPrimaryDark"
app:colorControlNormal="?android:attr/textColorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<TextView
android:id="@+id/actionbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:textColor="@color/colorPrimaryDark"
android:textSize="@dimen/action_bar_title_text_size"
android:textStyle="bold" />
<ImageView
android:id="@+id/toolbar_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:src="@drawable/btn_check_on"
android:visibility="gone" />
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<ImageView
android:id="@+id/drawerIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:src="@drawable/img_drawer_logo" />
</RelativeLayout>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
app:tabGravity="fill"
app:tabMaxWidth="0dp"
app:tabMode="fixed"
app:tabSelectedTextColor="@color/orange_100"
app:tabTextColor="@color/grey" />
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<include layout="@layout/horizontal_line" />
<!-- As the main content view, the view below consumes the entire
space available using match_parent in both dimensions. -->
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/baseline"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</LinearLayout>
<moebel.de.app.ui.view.MaterialSearchView
android:id="@+id/search_view"
style="@style/MaterialSearchViewStyle"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<moebel.de.app.ui.view.ShopFinderSearchView
android:id="@+id/shopfinder_search_view"
style="@style/ShopFinderSearchViewStyle"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<LinearLayout
android:id="@+id/layout_progressbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="@color/transparentColor"
android:gravity="center"
android:visibility="visible">
<ProgressBar
android:id="@+id/progressBar1"
style="@android:style/Widget.ProgressBar.Large"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
<RelativeLayout
android:id="@+id/drawer_left"
android:layout_width="@dimen/navigation_drawer_width"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@color/drawerListBackground"
android:clickable="true">
<ListView
android:id="@+id/navigation_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:choiceMode="singleChoice"
android:divider="@null"
android:listSelector="@drawable/drawer_list_selector" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:src="@drawable/img_drawer_logo" />
</RelativeLayout>
</android.support.v4.widget.DrawerLayout>
2.Run時間有此佈局添加片段:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:clickable="true"
android:orientation="vertical">
<LinearLayout
android:id="@+id/filterLayout"
android:layout_width="match_parent"
android:layout_height="44dp"
android:baselineAligned="false"
android:orientation="horizontal"
android:padding="@dimen/baseline">
<LinearLayout
android:id="@+id/categoryLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginEnd="2dp"
android:layout_marginRight="2dp"
android:layout_weight="0.5"
android:background="@color/grey_100"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:id="@+id/dotImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="2dp"
android:drawablePadding="@dimen/baseline"
android:src="@drawable/dot_image"
android:visibility="gone" />
<TextView
android:id="@+id/categoryText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableEnd="@drawable/ic_filter_arrow"
android:drawablePadding="@dimen/baseline"
android:drawableRight="@drawable/ic_filter_arrow"
android:text="@string/fragment_products_button_category"
android:textColor="@color/grey_400"
android:textSize="18sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/filter"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="2dp"
android:layout_marginStart="2dp"
android:layout_weight="0.5"
android:background="@color/grey_100"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:id="@+id/filterDotImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="2dp"
android:drawablePadding="@dimen/baseline"
android:src="@drawable/dot_image"
android:visibility="gone" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableEnd="@drawable/ic_filter_arrow"
android:drawablePadding="@dimen/baseline"
android:drawableRight="@drawable/ic_filter_arrow"
android:text="@string/fragment_products_button_filter"
android:textColor="@color/grey_400"
android:textSize="18sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.1">
<android.support.v7.widget.RecyclerView
android:id="@+id/product_grid_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never"
android:scrollbars="vertical"
tools:listitem="@layout/product_grid_item" />
<TextView
android:id="@+id/listEmpty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="Du hast keine Produkte auf Deinem Merkzettel"
android:visibility="gone" />
<LinearLayout
android:id="@+id/layout_progressbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="@color/transparentColor"
android:gravity="center"
android:visibility="visible">
<ProgressBar
android:id="@+id/progressBar1"
style="@android:style/Widget.ProgressBar.Large"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<View
android:id="@+id/transparent_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/transparentColor"
android:visibility="gone"
/>
</RelativeLayout>
<LinearLayout
android:id="@+id/layout_bottomProgressBar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.9"
android:background="@color/progressbarBackground"
android:gravity="center"
android:visibility="gone">
<ProgressBar
style="@android:style/Widget.ProgressBar.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
請幫我找出解決辦法。我是卡在這個問題不知道什麼是錯在此代碼。
[android棒棒糖工具欄:如何隱藏/ s如何滾動工具欄?](http://stackoverflow.com/questions/26539623/android-lollipop-toolbar-how-to-hide-show-the-toolbar-while-滾動) – SaravInfern