【问题标题】:Prevent Parent of Recycler From Collapse When Scrolling滚动时防止 Recycler 的父级折叠
【发布时间】:2020-09-05 10:24:55
【问题描述】:

当我在回收站视图中滚动时,我遇到了一个回收站视图的父级崩溃的问题。我希望“父级”在滚动回收站视图时不会崩溃。我尝试使用android:nestedScrollingEnabled="false",但这不起作用。任何援助将不胜感激。

xml

<?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=".MainActivity">

    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/constraintLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/green">
    </androidx.constraintlayout.widget.ConstraintLayout>
    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/bottomSheetLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/bottom_sheet_background_drawable"
        android:elevation="25dp"
        app:behavior_hideable="false"
        app:behavior_peekHeight="65dp"
        app:layout_behavior=".CustomSheetBehavior">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="8dp"
            android:background="@drawable/back_white"
            android:id="@+id/ll_search">

            <EditText
                android:layout_width="match_parent"
                android:layout_height="40dp"
                android:id="@+id/et_search"
                android:textSize="14sp"
                android:layout_marginTop="15dp"
                android:background="@drawable/custom_search2"
                android:drawableStart="@android:drawable/ic_menu_search"
                android:drawablePadding="6dp"/>
        </RelativeLayout>

        <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/recyclerView"
            android:layout_margin="8dp"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:background="@android:color/transparent"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/ll_search"
            tools:listitem="@layout/item_bottom_sheet_recycler_view">
        </androidx.recyclerview.widget.RecyclerView>

    </androidx.constraintlayout.widget.ConstraintLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

【问题讨论】:

    标签: android kotlin layout android-recyclerview scroll


    【解决方案1】:

    解决方案是在

    中使用recyclerView.stopNestedScroll()
        recyclerView.setOnTouchListener(OnTouchListener { v, event ->
    })
    

    【讨论】:

      猜你喜欢
      • 2017-08-21
      • 2019-11-28
      • 1970-01-01
      • 1970-01-01
      • 2019-09-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多