android - 在Android中向下滚动ListView时如何隐藏工具栏?(Xamarin)
问题描述
我在屏幕顶部有一个工具栏和一个 TabLayout,下面有一个 ViewPager。ViewPager 为每个选项卡显示不同的片段,但这些片段中的每一个本质上只是一个带有 ListView 的 RelativeLayout。我想让它在 ListView 向下滚动时,工具栏将隐藏自己(移到屏幕顶部看不见),当它向上滚动时,工具栏将再次出现。
我尝试遵循一些指南,但它似乎不起作用。更不用说我能找到的所有内容要么已经过时,要么使用了 AppBarLayout 下方的 RecyclerView。我需要一个 ViewPager 的选项卡,所以我不能有 RecylerView 那里。
我正在使用 API 级别 30,并且正在模拟的 Pixel 2 上进行测试。
这就是我的 XML 的样子:
<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">
<android.support.design.widget.AppBarLayout android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="enterAlways">
<android.support.v7.widget.Toolbar android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize">
<TextView android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"/>
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="32dp"
android:layout_below="@id/title"
android:layout_marginBottom="4dp"
app:tabMinWidth="96dp"
app:tabIndicatorHeight="4dp"
app:tabIndicatorFullWidth="false"
app:tabMode="scrollable">
<android.support.design.widget.TabItem android:text="@string/tab_1"/>
<android.support.design.widget.TabItem android:text="@string/tab_2"/>
<android.support.design.widget.TabItem android:text="@string/tab_3"/>
</android.support.design.widget.TabLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/appbar"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>
任何帮助将不胜感激,谢谢。
解决方案
推荐阅读
- c# - 使用 Nest 删除/取消索引设置
- javascript - “使用严格”在使用 Visual Studio Code 的 ES6 上不起作用
- reactjs - 如何在 React 中禁用热加载
- facebook - 此应用程序已被货币化:您尝试添加的应用程序已被 Facebook 受众网络中的企业货币化?
- html - Firefox 和 Chrome 的行高不同
- python - 单击浏览器上的按钮时如何关闭或终止我的 Django 应用程序
- python-3.x - 需要 Pycharm 配置帮助才能在 UNIX 中运行 Python 脚本
- javascript - 为什么 NextJS 的 getStaticPaths 在我运行下一个构建时会抛出错误?
- admob - 托管用户没有 AdSense 帐户
- c++ - 我应该如何修复我的 BMP280 传感器或 Arduino 代码以获得输出?