简体   繁体   English

ViewPager的列表向下滚动时,工具栏无法自动隐藏

[英]Toolbar can't auto-hide when viewpager's list scrolling down

I use CoordinatorLayout and AppBarLayout to try get the effect that the toolbar hides automatically as the ListView contained in the viewPager's Fragment scrolling down,but it doesn't work!The Toolbar never hide as I wish!Any of your suggestion will be appreciated! 我使用CoordinatorLayout和AppBarLayout尝试获得以下效果:当viewPager的Fragment中包含的ListView向下滚动时,工具栏会自动隐藏,但它不起作用!工具栏永远不会如我所愿地隐藏!您的任何建议将不胜感激! xml code: xml代码:

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

        <android.support.design.widget.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:orientation="vertical"
            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.TabLayout
                android:id="@+id/tabs"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@color/md_primary_green"
                app:tabGravity="fill"
                app:tabMode="fixed"
                app:tabSelectedTextColor="#ff0000"
                app:tabTextColor="@color/md_text"/>
        </android.support.design.widget.AppBarLayout>


        <!--<LinearLayout-->
            <!--android:layout_width="match_parent"-->
            <!--android:layout_height="match_parent"-->
            <!--android:orientation="vertical"-->
            <!--android:scrollbars="none"-->
             <!-->-->

            <android.support.v4.view.ViewPager
                android:id="@+id/viewgroup"
                android:layout_height="match_parent"
                app:layout_behavior="@string/appbar_scrolling_view_behavior"
                android:layout_width="match_parent">
            </android.support.v4.view.ViewPager>
        <!--</LinearLayout>-->
    </android.support.design.widget.CoordinatorLayout>

原因是AppBarLayout无法与旧控件完全兼容。当我用RecycleView替换ListView时,它运行良好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当使用协调器布局滚动我的recyclerview时,如何提供自动隐藏/显示工具栏? - How can I provide auto-hide/show toolbar, when scroll my recyclerview with coordinator layout? WebView滚动时无法隐藏工具栏 - can`t hide toolbar when webview scrolling 无法滚动 RecyclerView,尝试在滚动时隐藏工具栏 - Can't scroll RecyclerView, when try to hide toolbar on scrolling 使用滚动RecyclerView时如何在ViewPager中隐藏工具栏? - How to hide the toolbar in a ViewPager when using Scrolling RecyclerView? 滚动时工具栏不会隐藏 - Toolbar doesn't hide when scrolling Android:向上滚动时显示工具栏(向上拖动),向下滚动时隐藏(向下拖动) - Android: Show toolbar when scrolling UP(Drag UP) and hide when scrolling down(Drag down) 当列表滚动到顶部时如何制作隐藏/显示工具栏 - How to make hide/show toolbar when our list scrolling to the top 工具栏下的GridView - 滚动时隐藏工具栏 - GridView under Toolbar - Hide ToolBar when Scrolling 向上滚动时隐藏ViewPager选项卡。 - Hide ViewPager tabs when scrolling up. 如何为我的Android应用程序实现类似“自动隐藏导航”的Chrome? - How can I implement a chrome like “auto-hide navigation” for my Android app?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM