android - 禁用 AppBar 滚动
问题描述
问题是将 AppBar 设置为顶部的动画(我想禁用滚动)
在下面的代码中,当我们滑动 nestedScrollview 时,appBar 滚动到顶部... 那么我想要得到什么结果? 我想禁用滚动 Appbar 但嵌套滚动视图(见下面的代码)与她的子视图可以滚动到顶部(结果“高度”将具有“match_parent”)与重叠的 AppBar
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="300dp"
android:background="@color/teal_200"
app:layout_behavior="@string/behavior"
app:elevation="0dp">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="@+id/collapsingLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbarStyle="insideInset"
app:collapsedTitleGravity="center"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<TextView
android:gravity="center"
android:text="Do not scroll to top"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:id="@+id/nestScrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:fillViewport="true"
android:scrollbars="none"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:background="@color/white"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:id="@+id/jumpUrl"
android:gravity="center"
android:layout_height="wrap_content"
android:background="@color/white"
android:layout_gravity="center"
android:drawableBottom="@drawable/ic_android_black_24dp"
android:text="Scroll to top without scrolling AppBar" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
解决方案
推荐阅读
- c++ - 以下搜索算法的时间复杂度是多少?
- java - 如何查看通话记录中的未接来电?
- react-native - 如何访问 React Native 中的数据属性?
- python - Python 例外:数据必须是试图获取两列的一维熊猫
- r - 当我添加 geom_text() 以在 ggplot2 中的条形上显示标签时条形消失
- java - 我想更改材质组件主题中的标题栏文本颜色。任何帮助将不胜感激
- firebase - 将应用程序启动到应用商店后,如何将多个文档添加到 Firestore?
- javascript - 提交按钮不起作用重新加载页面或提交表单 MVC
- javascript - 滚动时如何替换 URL?
- reactjs - 在 next.js 中将反应导入页面