首页 > 解决方案 > On click isn't fired on recyclerview in nestedscrollview under coordinatorlayout in Android

问题描述

There're two dimentional recyvlerview under nested scroll view under coordinator layout. Clicking to RC items isn't firing with coordinator layout, without it firing good. How to solve it?

<?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:id="@+id/main_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true">

<androidx.core.widget.NestedScrollView
    android:id="@+id/main_nsv"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#AB9984"
    android:fillViewport="true"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">


    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/main_recycler"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:descendantFocusability="blocksDescendants"
        android:scrollbars="none"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        tools:context=".activity.MainActivity">


    </androidx.recyclerview.widget.RecyclerView>

</androidx.core.widget.NestedScrollView>

</androidx.coordinatorlayout.widget.CoordinatorLayout>

标签: androidandroid-recyclerview

解决方案


推荐阅读