[英]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.