关注 tutorial ,我创建了这个布局:
这是我的布局 xml 文件:
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/tabanim_maincontent"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/tabanim_appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="@+id/tabanim_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
<android.support.design.widget.TabLayout
android:id="@+id/tabanim_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/tabanim_viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
我想要的是,当我将滚动条留在中间时(当应用栏的下部可见时),应用栏应该隐藏自己或完全显示自己 就像在 google play 商店中发生的那样:
请注意,在 google play 的情况下,当没有手指触摸屏幕时,应用栏永远不会半隐藏
如何把应用栏做成这样?
谢谢
最佳答案
将捕捉标志添加到滚动标志:
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|enterAlways|snap" />
这是刚刚在 Support Library v23.1.0 中添加的.
关于android - 滚动时如何自动隐藏 v7 appbar 部分隐藏它 - android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33436398/