material-ripple icon indicating copy to clipboard operation
material-ripple copied to clipboard

Ripple layout in adapter

Open ghost opened this issue 9 years ago • 2 comments

Hello,

I have problem with mateerial-ripple. I used this layout in adapter. Adapter xml look like this:

<com.balysv.materialripple.MaterialRippleLayout
    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:paddingTop="1dp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    app:mrl_rippleDelayClick="true"
    style="@style/RippleWhite" >

....<!-- other widget -->
<ImageButton
                android:id="@+id/following_user_btn"
                style="@style/ButtonStyle"
                android:layout_width="48dp"
                android:layout_height="28dp"
                android:layout_marginRight="0dp"
                android:background="@drawable/button_user_action_v2"
                android:src="@drawable/button_follow_user"/>

</com.balysv.materialripple.MaterialRippleLayout>

OnClick on ImageButton in getView dosen't work. I dont why.

ghost avatar Jun 10 '15 12:06 ghost

If you mean that the ripple isn't displayed on a click, I had the same problem. You can fix it by setting mrl_rippleOverlay to true, or removing the background on your child view.

fractalwrench avatar Jun 14 '15 18:06 fractalwrench

hi add your OnClickListener to your MaterialRippleLayout =>

i describ in this link: http://stackoverflow.com/questions/28217096/no-touch-feedback-on-recyclerview-when-using-ripple-effect-library/33022891#33022891

ex: like this:

public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {

    private MaterialRippleLayout mRipple;
    private Rec_ItemClickListener rec_itemClickListener;

    public TextView tvTitle;

    public ViewHolder(View v) {
        super(v);
        tvTitle=(TextView)v.findViewById(R.id.cm_title_cat);
        mRipple=(MaterialRippleLayout)v.findViewById(R.id.ripple_custom_cat);
        v.setOnClickListener(this);
        mRipple.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(ac, " clicked in mripple", Toast.LENGTH_LONG).show();

            }
        });
    }


    public void setClickListener(Rec_ItemClickListener clickListener){

        this.rec_itemClickListener=clickListener;
    }

    @Override
    public void onClick(View v) {

        rec_itemClickListener.onClick(v,getAdapterPosition(),false);

    }


}

abbasfisal avatar Oct 08 '15 18:10 abbasfisal