首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何隐藏listview滚动条上的工具栏?

如何隐藏listview滚动条上的工具栏?
EN

Stack Overflow用户
提问于 2016-03-14 15:20:10
回答 1查看 2K关注 0票数 0

这是我的布局xml代码

我已经有listview scroll listener的回调,但是如果我这样做的话

代码语言:javascript
运行
复制
  collapsingToolbarLayout.setVisibility(View.GONE);

这是简单的隐藏工具栏的地方滚动效果,但我想滚动效果,请帮助。

代码语言:javascript
运行
复制
<android.support.design.widget.AppBarLayout
    android:id="@+id/id_toolbar_container"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fitsSystemWindows="true">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:visibility="gone"
        app:layout_collapseMode="pin"
        app:layout_scrollFlags="scroll|exitUntilCollapsed" />
</android.support.design.widget.AppBarLayout>

<android.support.design.widget.CoordinatorLayout
    android:id="@+id/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@id/id_toolbar_container">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/id_appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:elevation="0dp">

        //This is the toolbar which i want to hide on scroll of listview
        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsingToolBar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_scrollFlags="enterAlwaysCollapsed">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@color/white">

                <android.support.design.widget.TabLayout
                    android:id="@+id/tabs"
                    android:layout_width="wrap_content"
                    android:layout_height="?attr/actionBarSize"
                    android:layout_alignParentLeft="true"
                    android:layout_alignParentStart="true"
                    android:layout_marginTop="5dp"
                    app:tabMinWidth="75dp"
                    app:tabIndicatorColor="@color/deep_blue"
                    app:tabSelectedTextColor="@color/background"
                    app:tabTextAppearance="@style/MyTabLayoutTextAppearance"
                    app:tabTextColor="@color/myGrey" />

            </RelativeLayout>
        </android.support.design.widget.CollapsingToolbarLayout>

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

    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

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

EN

回答 1

Stack Overflow用户

发布于 2016-03-14 16:18:23

滚动行为依赖于支持嵌套滚动的视图,这是在视图树中向上传播滚动事件所必需的。

在api-21中添加了setNestedScrollingEnabled()方法。为了让折叠工具栏在api-21及更高版本上工作,在ListView上调用它:

代码语言:javascript
运行
复制
myListView.setNestedScrollingEnabled(true);

为了让它在较低的api级别上工作,您需要将您的ListView转换为支持向下滚动到api-7的RecyclerView,因为它来自v7支持库。

有关使用RecyclerView的完整示例,请参阅here

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35981613

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档