There are some similar questions. But they are not resolved!
Set RippleDrawable corner radius programmatically
I know that this behaviour can be done using xml file. But I must it programmatically.
My code is below:
GradientDrawable gd = new GradientDrawable();
gd.setColor(Color.YELLOW);
gd.setStroke(2, Color.RED);
gd.setCornerRadius(45.0f);
view.setBackground(gd);
int[] colors = new int[]{Color.GRAY};
int[][] states = new int[][]{ new int[]{}};
ColorStateList stateList = new ColorStateList(states, colors);
Drawable mask = getResources().getDrawable(R.drawable.icon1);
RippleDrawable rippleDrawableBackgorund = new RippleDrawable(stateList, view.getBackground(), mask);
view.setBackground(rippleDrawableBackgorund);
Screenshot is below for pressed state:
How can I set borderRadius for RippleDrawable? Also, rippleDrawableBackgorund.setRadius
changes this effect for hover state.