balysv / material-ripple

Android L Ripple effect wrapper for Views
Apache License 2.0
2.36k stars 479 forks source link

setOnClickListener doesn't work when MaterialRippleLayout is used from a Custom View #91

Open spapapan opened 1 year ago

spapapan commented 1 year ago

This is the Layout I am using which works perfectly when I use it inside the .xml of my Fragment:

         <com.balysv.materialripple.MaterialRippleLayout
                android:id="@+id/orderByFilterBtn"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:mrl_rippleColor="@color/gray_light"
                android:layout_margin="2dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="horizontal">

                    <TextView
                        android:id="@+id/orderByFilterTxt"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center_vertical"
                        android:text="@string/popular"
                        android:layout_marginStart="10dp"
                        />

                    <ImageView
                        android:id="@+id/orderByFilterDown"
                        android:layout_width="15dp"
                        android:layout_height="15dp"
                        android:layout_marginEnd="10dp"
                        android:layout_marginStart="4dp"
                        android:layout_gravity="center_vertical"
                        android:src="@drawable/baseline_arrow_drop_down_gray_24dp"
                        />

                </LinearLayout> 

            </com.balysv.materialripple.MaterialRippleLayout>

But when I try to use it from a Custom View with exactly the same code, the click event never gets called.

view.findViewById(R.id.orderByFilterBtn).setOnClickListener(s->{ //Click Event });

Any ideas why?