material-ripple
material-ripple copied to clipboard
the effect on cardview show behind it
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
hii I had the same problem. have you find solution ?
Hii @Abdelsattar I found solution . in xml file set this attribute card_view:mrl_rippleOverlay="true"
. It will do proper effect .
All part of parent has ripple
, we want to set ripple
just for cardview
with it's radius
@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.
@TechnologyMaster RecyclerView
is not an AdapterView
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 !
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);
}
}