如何隐藏动作条,而在Android的滚动的ListView? [英] How to hide ActionBar while scrolling ListView in android?

查看:214
本文介绍了如何隐藏动作条,而在Android的滚动的ListView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建一个列表视图和动作条它向下滚动时和滚动的时候了,必须重新出现将隐藏的接口。

I need to create an interface with a listview and an actionbar which will hide when scrolling down and when scrolling up it must reappear.

下面的指南并没有帮助我:

The following guides didn't help me:

<一个href="https://mzgreen.github.io/2015/06/23/How-to-hideshow-Toolbar-when-list-is-scrolling%28part3%29/" rel="nofollow">https://mzgreen.github.io/2015/06/23/How-to-hideshow-Toolbar-when-list-is-scrolling%28part3%29/ https://github.com/ksoichiro/Android-ObservableScrollView

我需要的是这样的:

推荐答案

如果你想获得一个列表,此行为,您应该:

If you would like to obtain a list with this behaviour, you should:

  • 添加与设计支持库编译com.android.support:design:22.2.0
  • 使用一个 CoordinatorLayout 有一个工具栏,你必须定义应用程序:layout_scrollFlags =滚动| enterAlways
  • 使用一个的 RecyclerView 代替的ListView 。如上所述<一个href="http://stackoverflow.com/questions/30696611/design-lib-coordinatorlayout-collapsingtoolbarlayout-with-gridview-listview/30885092#30885092">here 的ListView 的GridView 有预期的行为 CoordinatorLayout 只有API> 21。在这种情况下,你必须使用 setNestedScrollingEnabled(真);
  • add the design support library with compile 'com.android.support:design:22.2.0'
  • Use a CoordinatorLayout with a Toolbar where you have to define app:layout_scrollFlags="scroll|enterAlways"
  • Use a RecyclerView instead of a ListView. As described here ListView and the GridView have the expected behavior with the CoordinatorLayout only with API>21. In this case you have to use setNestedScrollingEnabled(true);

href="http://android-developers.blogspot.de/2015/05/android-design-support-library.html" rel="nofollow">官方博客帖子的

The official blog post shows this case:

<android.support.design.widget.CoordinatorLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

     <! -- Your Scrollable View -->
    <android.support.v7.widget.RecyclerView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior" />

    <android.support.design.widget.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
          <android.support.v7.widget.Toolbar
                  ...
                  app:layout_scrollFlags="scroll|enterAlways">


     </android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>

这篇关于如何隐藏动作条,而在Android的滚动的ListView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆