我有一个包含工具栏,选项卡和列表视图的应用程序,我想在向下滚动时隐藏工具栏,我尝试了许多解决方案,但都无济于事。
这是MainActivity布局的xml代码:
<android.support.v4.widget.DrawerLayout
.......
>
<LinearLayout
.....
>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/primary_color"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_scrollFlags="scroll|enterAlways"
>
<Button
....
/>
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
style="@style/CategoryTab"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
<android.support.design.widget.NavigationView
android:background="@color/primary_color"
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:itemTextColor="@color/text_drawer_color"
app:itemIconTint="@color/text_drawer_color"
app:headerLayout="@layout/nav_header"
app:menu="@menu/drawer_menu"
/>
</android.support.v4.widget.DrawerLayout>
,这是包含listview的片段的xml代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/tan_background"
>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_alignParentTop="true"
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="4dp"
android:background="@color/tan_background"
android:divider="@color/tan_background"
android:dividerHeight="8dp"
android:drawSelectorOnTop="true"
android:focusable="true"
android:orientation="vertical"
android:layout_above="@+id/LL_contentProgressBarParent"
>
</ListView>
</RelativeLayout>
有什么解决办法吗?