I create a RippleDrawable
like below. But I can't change the corner radius of the RippleDrawable.
It doesn't have a method like setCornerRadii(float[] f)
.
public static RippleDrawable getPressedColorRippleDrawable(int normalColor, int pressedColor) {
if (Build.VERSION.SDK_INT>=21) {
RippleDrawable rippleDrawable = new RippleDrawable(getPressedColorSelector(normalColor, pressedColor), getColorDrawableFromColor(normalColor), null);
//rippleDrawable.setRadius((int) Manager.convertDpToPixel(5));
return rippleDrawable;
}
else
return null;
}
And the other functions are
public static ColorStateList getPressedColorSelector(int normalColor, int pressedColor) {
return new ColorStateList(
new int[][]
{
new int[]{android.R.attr.state_pressed},
new int[]{android.R.attr.state_focused},
new int[]{android.R.attr.state_activated},
new int[]{}
},
new int[]
{
pressedColor,
pressedColor,
pressedColor,
normalColor
}
);
}
public static ColorDrawable getColorDrawableFromColor(int color) {
return new ColorDrawable(color);
}
How can I do it?