【发布时间】:2015-11-17 16:07:21
【问题描述】:
在阅读了很多关于自动隐藏工具栏/标签栏的教程之后。我遇到了材料设计支持库,我们可以使用它轻松地自动隐藏工具栏/标签栏:
app:layout_scrollFlags="scroll|enterAlways"(在 XML 工具栏中) 这是支持库参考 --> 编译'com.android.support:design:22.2.0'
但我需要的是在向上滚动时自动隐藏 TabLayout(Tabbar 而不是工具栏),在向下滚动时自动隐藏 TabLayout。
这是我的activity_main。
<android.support.design.widget.AppBarLayout
android:id="@+id/id_appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true">
<android.support.v7.widget.Toolbar
android:id="@+id/id_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways" />
<android.support.design.widget.TabLayout
android:id="@+id/id_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/id_viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
我检查了在 TabLayout 中添加 app:layout_scrollFlags="scroll|enterAlways",但它不起作用。任何人都可以帮助我实现它。
【问题讨论】:
标签: android-studio material-design android-appbarlayout