Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clicking Floating ActionButton on right corner makes RecyclerView item get clicked

I want to add Floating Action Button on recyclerview but problem is when i click on Floating Action Button Recyclerview item get clicked how to remove this problem

see below code

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".screens.ShowSubjectsFrag"
    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.support.v7.widget.RecyclerView
        android:id="@+id/MainList"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center">
    </android.support.v7.widget.RecyclerView>
    <android.support.design.widget.FloatingActionButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@android:drawable/ic_input_add"
        app:layout_anchor="@id/MainList"
        android:layout_margin="@dimen/fab_margin"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true" />
</RelativeLayout>
like image 977
AlienArt Software Avatar asked Dec 25 '15 05:12

AlienArt Software


1 Answers

Write the View#onClickListener for the FloatingActionButton in your Activity/Fragment because currently your FloatingActionButton is not registered for any event. Had the same problem Cheers

like image 124
Mohammed Rampurawala Avatar answered Oct 13 '22 17:10

Mohammed Rampurawala