balysv / material-ripple

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

the effect on cardview show behind it #70

Open Abdelsattar opened 7 years ago

Abdelsattar commented 7 years ago

when i add it as parent and try it it just show the effect in the border of the card view behind it not the card view itself

TechnologyMaster commented 7 years ago

hii I had the same problem. have you find solution ?

TechnologyMaster commented 7 years ago

Hii @Abdelsattar I found solution . in xml file set this attribute card_view:mrl_rippleOverlay="true" . It will do proper effect .

Hitexroid commented 7 years ago

All part of parent has ripple, we want to set ripplejust for cardviewwith it's radius

TechnologyMaster commented 7 years ago

@Abdelsattar it's working perfect for me. In adapter item layout card view is used . so this is worked for me. Have you also added this property ? card_view:mrl_rippleInAdapter="true" if set then in adapter it's effect will work. Hope this Help.

Hitexroid commented 7 years ago

@TechnologyMaster RecyclerView is not an AdapterView

Hitexroid commented 6 years ago

i have an idea , extend MaterialRippleLayout to CardView instead of FrameLayout

example : public class MaterialRippleLayout extends CardView {

but it has a problem , It lefts a dot color in your item during scroll !

Hitexroid commented 6 years ago

i have another idea too 😃👍

Edit this line (777) of MaterialRippleLayout my mean ---> public MaterialRippleLayout create() {

edit it to public CardView create() {

then

remove these lines (805 ~ 811) ---> my mean 👇

layout.addView(child, new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));

            if (parent != null) {
                parent.addView(layout, index, params);
            }

            return layout;

then , paste these code 👇

 CardView cardView = new CardView(context);
            cardView.addView(layout);
            layout.addView(child, new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));

            if (parent != null) {
                parent.addView(cardView, index, params);
            }

            return cardView;

now in ViewHolder in Adapter

   public static class ViewHolder extends RecyclerView.ViewHolder {
        CardView cardView;
        View yourView;

        public ViewHolder(View itemView) {
            super(itemView);
            cardView = (CardView) itemView;
            MaterialRippleLayout rippleLayout = (MaterialRippleLayout) cardView.getChildAt(0);
            yourView = (ViewGroup) rippleLayout.getChildAt(0);
        }
    }