嵌套滚动视图不使用 CoordinatorLayout 滚动



尝试使用 NestedScrollViewCoordinatorLayout内滚动内容不适用于片段的以下布局:

<?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"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">
    <com.google.android.material.appbar.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true">
        <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </com.google.android.material.appbar.AppBarLayout>
    <androidx.core.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true"
        android:scrollbars="none"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="24dp"
            android:orientation="vertical">
            <!-- Scrollable content -->
        </LinearLayout>
    </androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

如何使NestedScrollView内的内容可滚动? windowSoftInput设置为托管活动的adjustResize,主题为Theme.MaterialComponents.Light.NoActionBar 。此外,活动不是全屏的。

必须应用此处提到的解决方法:https://stackoverflow.com/a/36322516 因为没有其他东西对我有用。因此,将此答案标记为已接受,直到将工作解决方案作为答案发布为止

最新更新