小编mat*_*eog的帖子

具有约束布局的 NestedScrollView 不滚动

我的 xml 由一个约束布局组成。其中有 2 个按钮和 1 个嵌套滚动视图。里面ScrollView有各种元素,包括回收视图。我希望回收视图不滚动,而只滚动嵌套的滚动视图。我在此模式 ( recyclerView.setNestedScrollingEnabled(false);) 中禁用了回收视图的滚动,但问题是嵌套滚动视图不滚动。你能帮助我吗?我附上下面的代码。

代码以这种模式开始:

<?xml version="1.0" encoding="utf-8"?>

<android.support.constraint.ConstraintLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <TextView
    android:id="@+id/azzera"
    android:layout_width="120dp"
    android:layout_height="40dp"
    android:layout_marginStart="40dp"
    android:layout_marginBottom="28dp"
    android:background="@drawable/rounded_4lati"
    android:backgroundTint="@color/azzurro"
    android:elevation="@dimen/dimen8"
    android:paddingTop="@dimen/dimen8"
    android:text="@string/azzera"
    android:textAlignment="center"
    android:textColor="#FFFFFF"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent" />

<TextView
    android:id="@+id/conferma"
    android:layout_width="120dp"
    android:layout_height="40dp"
    android:layout_marginEnd="16dp"
    android:layout_marginBottom="28dp"
    android:background="@drawable/rounded_4lati"
    android:backgroundTint="@color/azzurro"
    android:paddingTop="@dimen/dimen8"
    android:text="@string/conferma"
    android:textAlignment="center"
    android:textColor="#FFFFFF"
    android:elevation="@dimen/dimen8"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent" />

<android.support.v4.widget.NestedScrollView 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:fillViewport="true"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    >

    <android.support.constraint.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <View
            android:id="@+id/view1"
            android:layout_width="0dp"
            android:layout_height="48dp"
            android:background="@color/white"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.0"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <View
            android:id="@+id/view2" …
Run Code Online (Sandbox Code Playgroud)

android android-recyclerview android-nestedscrollview android-constraintlayout

5
推荐指数
2
解决办法
3907
查看次数