【问题标题】:NestedScrollView not scrolling with CoordinatorLayoutNestedScrollView 不使用 CoordinatorLayout 滚动
【发布时间】:2019-09-17 23:01:18
【问题描述】:

尝试使用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。活动也不是全屏的。

【问题讨论】:

  • 您是否要制作折叠布局?
  • @Mr.AF No. 我用CoordinatorLayout 在状态栏后面画图
  • 嵌套滚动视图中是否有可滚动视图或者它是空的?
  • 我在嵌套滚动视图中有一个表单,所以嵌套滚动视图中有很多视图应该可以滚动

标签: android android-coordinatorlayout android-design-library android-nestedscrollview androiddesignsupport


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-08-28
    • 1970-01-01
    • 2016-04-24
    • 2016-11-02
    • 2016-12-18
    • 1970-01-01
    • 1970-01-01
    • 2017-01-16
    相关资源
    最近更新 更多