android - android 行为在 androidx.core.widget.NestedScrollView 中不起作用
问题描述
我有一个CoordinatorLayout
并且有AppBarLayout
:
<?xml version="1.0" encoding="utf-8"?>
<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=".Pages.Artist.Show">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="300dp"
android:id="@+id/AppBar">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="@+id/toolbarLayout"
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:contentScrim="?attr/colorPrimary"
app:collapsedTitleGravity="center">
<ImageView
android:contentDescription="@null"
android:id="@+id/ArtistImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax"/>
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_height="?attr/actionBarSize"
android:layout_width="match_parent"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
</com.google.android.material.appbar.CollapsingToolbarLayout>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
</androidx.core.widget.NestedScrollView>
</com.google.android.material.appbar.AppBarLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
在NestedScrollView
我无法设置layout_behavior!
为什么我们在 androidx 中没有 layout_behavior 呢?
解决方案
您可以在NestedScrollView标记中设置这样的布局行为。
app:layout_behavior="@string/appbar_scrolling_view_behavior"
推荐阅读
- postgresql - 用户插补时插入语句不起作用
- python - Python如何使用绝对导入
- linux - 有没有办法通过命令行从网页转储加载的脚本?
- python - keras.Model 和 keras.engine.training.Model 有什么区别?
- php - 如何使用 PHP 在 Twilio 中传递自定义参数?
- android - 如何在 Android 中实现类似 Page/Form sheet 的 iOS 13 新卡片?
- javascript - 如何在 react-native 中过滤 JavaScript 对象
- mysql - 如何更新每列中具有不同值的多行
- amazon-web-services - 如何使用数据管道中的实例队列旋转 EMR 集群?
- c# - 如何在 foreach 循环中将 JsonConvert jsonString 映射到 jsonObject?