<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/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/tab_bar" />
<com.whl.handytabbar.HandyTabBar
android:id="@+id/tab_bar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:background="@drawable/custom_shadow" />
</android.support.design.widget.CoordinatorLayout>
-1
A
回答
2
工具栏位于AppBarLayout内部,可能位于您的CoordinatorLayout内部,因此应如此工作。
AppBarLayout appBarLayout = (AppBarLayout)findViewById(R.id.appBar);
appBarLayout.setExpanded(true, true);
或者崩溃的工具栏,然后这样的事情应该工作
AppBarLayout appBarLayout = (AppBarLayout)findViewById(R.id.appBar);
appBarLayout.setExpanded(false, true);
0
请点击此链接,你将在这里得到答案:
0
你需要这个app:layout_behavior="@string/appbar_scrolling_view_behavior"
在您的滚动查看下面:
<android.support.v7.widget.RecyclerView
android:id="@+id/rvToDoList"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
,我们需要定义AppBarLayout和View 将滚动之间的关联。向RecyclerView或 添加应用程序:layout_behavior或其他任何能够嵌套滚动的View,例如NestedScrollView。 支持库包含一个特殊字符串资源 @ string/appbar_scrolling_view_behavior映射到 AppBarLayout.ScrollingViewBehavior,用于在此特定视图上发生滚动事件时通知 AppBarLayout。必须在触发事件的视图上建立 行为。
你应该看看This Guide
相关问题
- 1. 工具栏不隐藏/显示在滚动协调器布局
- 2. 防止键盘布局隐藏工具栏,但显示滚动内容
- 3. 隐藏工具栏暂时滚动时
- 4. CollapsingToolbarLayout并滚动时隐藏工具栏
- 5. 隐藏工具栏滚动时recyclerview
- 6. 当用户滚动时隐藏在导航栏下的内容
- 7. 当在嵌套片段中滚动RecyclerView时隐藏工具栏
- 8. 隐藏工具栏和抽屉滚动
- 9. 工具栏不会在列表中滚动隐藏
- 10. Android工具栏+选项卡布局+抽屉,滚动时隐藏工具栏并将TabLayout置顶部
- 11. 不能老是隐藏工具栏时的WebView滚动
- 12. 工具栏在segue后不会隐藏
- 13. 滚动 - 隐藏内容
- 14. 隐藏滚动内容
- 15. 隐藏内容滚动
- 16. 当在appbar布局中滚动时协调器布局的内容不会滚动
- 17. AppBarLayout滚动内容下方工具栏
- 18. 折叠工具栏不会在依从布局中滚动时折叠
- 19. 滚动工具栏不工作在Android使用框架布局
- 20. 当我选择自动布局选项时,ScrollView不会滚动
- 21. 折叠工具栏向上滚动时隐藏并向下滚动时显示
- 22. 如何在滚动片段时隐藏工具栏?
- 23. 隐藏工具栏时无法启用webview的滚动行为
- 24. 如何隐藏工具栏滚动时使用recyclerView里面NestedScrollView
- 25. 在android中滚动时隐藏工具栏
- 26. 为什么工具栏在滚动时没有隐藏?
- 27. 使用Coordinator Layout滚动recyclerview时无法隐藏工具栏
- 28. 隐藏工具栏
- 29. 隐藏工具栏
- 30. 如何滚动工具栏和标签布局之间的内容
这是一些文档[https://developer.android.com/reference/android/support/design/widget/AppBarLayout.html#setExpanded(boolean)]供参考。 –