朋友们,我想在用户在屏幕上滚动时使用ObservableScrollView
隐藏我的工具栏。
相关屏幕布局如下所示
我的布局文件如下
main.xml中
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:background="@color/header_bg"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/container_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar" />
<View
android:layout_width="match_parent"
android:layout_height="4dp"
android:background="@drawable/shadow" />
<customedittext.RegularEditText
android:id="@+id/edt_search"
style="@style/Edittext"
android:background="@drawable/search_rect"
android:drawableRight="@drawable/search"
android:hint="Search Product"
android:padding="@dimen/margin_10dp"
android:text=""
android:textSize="@dimen/text_12" />
</LinearLayout>
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="fill_parent"
android:layout_height="match_parent"
>
<com.github.ksoichiro.android.observablescrollview.ObservableScrollView
android:id="@+id/scroll"
android:layout_width="match_parent"
android:fitsSystemWindows="true"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/scl_rels"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="@+id/rel_pager"
android:layout_width="match_parent"
android:layout_height="100dp"
>
<android.support.v4.view.ViewPager
android:id="@+id/pager_introduction"
android:layout_width="match_parent"
android:layout_height="100dp"
android:fitsSystemWindows="true"
tools:listitem="@layout/pager_item" />
<LinearLayout
android:id="@+id/viewPagerCountDots"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_marginBottom="@dimen/margin_10dp"
android:gravity="center|bottom"
android:orientation="horizontal" />
</RelativeLayout>
<LinearLayout
android:id="@+id/scl_ll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/rel_pager"
android:orientation="vertical">
<LinearLayout
android:id="@+id/ll_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_10dp"
android:layout_marginLeft="@dimen/margin_10dp"
android:layout_marginRight="@dimen/margin_10dp"
android:layout_marginBottom="@dimen/margin_5dp"
android:orientation="horizontal">
<customtext.BoldText
android:id="@+id/txt_title1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:textSize="@dimen/text_14"
android:text="DEAL OF THE DAY"
android:textColor="#333333"
/>
<customtext.RegularText
android:id="@+id/txt_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:gravity="right"
android:text="VIEW ALL"
android:textSize="@dimen/text_10"
android:textColor="@color/blue_common"
/>
</LinearLayout>
<HorizontalScrollView
android:id="@+id/hor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/search_rect"
android:scrollbars="none">
<LinearLayout
android:id="@+id/ll_child"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"></LinearLayout>
</HorizontalScrollView>
<LinearLayout
android:id="@+id/ll_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_10dp"
android:layout_marginLeft="@dimen/margin_10dp"
android:layout_marginRight="@dimen/margin_10dp"
android:layout_marginBottom="@dimen/margin_5dp"
android:orientation="horizontal">
<customtext.BoldText
android:id="@+id/txt_title2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:textSize="@dimen/text_14"
android:text="FOOD AND NUTRITION"
android:textColor="#333333"
/>
<customtext.RegularText
android:id="@+id/txt_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:gravity="right"
android:text="VIEW ALL"
android:textSize="@dimen/text_10"
android:textColor="@color/blue_common"
/>
</LinearLayout>
<HorizontalScrollView
android:id="@+id/hor1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/search_rect"
android:scrollbars="none">
<LinearLayout
android:id="@+id/ll_child1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"></LinearLayout>
</HorizontalScrollView>
<LinearLayout
android:id="@+id/ll_3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_10dp"
android:layout_marginLeft="@dimen/margin_10dp"
android:layout_marginRight="@dimen/margin_10dp"
android:layout_marginBottom="@dimen/margin_5dp"
android:orientation="horizontal">
<customtext.BoldText
android:id="@+id/txt_title3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:textSize="@dimen/text_14"
android:text="HOME AND FURNITURE"
android:textColor="#333333"
/>
<customtext.RegularText
android:id="@+id/txt_3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:gravity="right"
android:text="VIEW ALL"
android:textColor="@color/blue_common"
android:textSize="@dimen/text_10" />
</LinearLayout>
<HorizontalScrollView
android:id="@+id/hor2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/search_rect"
android:scrollbars="none">
<LinearLayout
android:id="@+id/ll_child3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"></LinearLayout>
</HorizontalScrollView>
<LinearLayout
android:id="@+id/ll_4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_10dp"
android:layout_marginLeft="@dimen/margin_10dp"
android:layout_marginRight="@dimen/margin_10dp"
android:layout_marginBottom="@dimen/margin_5dp"
android:orientation="horizontal">
<customtext.BoldText
android:id="@+id/txt_title4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:textSize="@dimen/text_14"
android:text="ADDTOBUY FASHION SALE"
android:textColor="#333333"
/>
<customtext.RegularText
android:id="@+id/txt_4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:gravity="right"
android:text="VIEW ALL"
android:textColor="@color/blue_common"
android:textSize="@dimen/text_10"/>
</LinearLayout>
<HorizontalScrollView
android:id="@+id/hor3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/search_rect"
android:scrollbars="none">
<LinearLayout
android:id="@+id/ll_child4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"></LinearLayout>
</HorizontalScrollView>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</com.github.ksoichiro.android.observablescrollview.ObservableScrollView>
</FrameLayout>
</LinearLayout>
<!--<include
android:id="@+id/toolbar"
layout="@layout/toolbar" />
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />-->
<!-- The navigation drawer -->
<ListView
android:id="@+id/navdrawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@android:color/white"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:layerType="software"
android:dividerHeight="1dp"
android:drawSelectorOnTop="false">
</ListView>
<!--<ExpandableListView
android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@android:color/white"
android:cacheColorHint="#00000000"
android:divider="@android:color/transparent"
android:dividerHeight="0dp" />-->
当我在代码上方运行时,它会隐藏toolbar
但在底部保留一些空格,如下所示:
我知道如何解决这个问题?