gpt4 book ai didi

android-appbarlayout - Androidx ScrollView 行为不起作用

转载 作者:行者123 更新时间:2023-12-04 11:46:55 26 4
gpt4 key购买 nike

切换到 androidx 后,以下代码停止工作。工具栏下面的TextView用于滚动内容,但现在不滚动。我设法使它仅在将相同的scrollFlags设置为Toolbar时才起作用,但我希望将其保留在原位。除了将工具栏移出AppBarLayout和CoordinatorLayout之外,还有其他解决方案吗?

<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<androidx.appcompat.widget.Toolbar
app:title="Non-scrollable title"
android:layout_width="wrap_content"
android:layout_height="?android:attr/actionBarSize"/>

<TextView
app:layout_scrollFlags="scroll"
android:layout_margin="16dp"
android:textSize="20sp"
android:text="this should scroll with the content"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

</com.google.android.material.appbar.AppBarLayout>

<androidx.core.widget.NestedScrollView
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:layout_height="match_parent">

<!-- some scrollable content here -->

</androidx.core.widget.NestedScrollView>

</androidx.coordinatorlayout.widget.CoordinatorLayout>

最佳答案

替换属性
老的:app:layout_behavior="@string/appbar_scrolling_view_behavior"
新的:app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
并添加

implementation 'com.google.android.material:material:1.0.0'

关于android-appbarlayout - Androidx ScrollView 行为不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55649385/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com