[英]Top rounded gradient drawable
i need to create a GradientDrawable object with only the top rounded corners. 我需要创建仅具有顶部圆角的GradientDrawable对象。
Actually i'm using this method: 实际上我正在使用这种方法:
public static GradientDrawable generateGradientBackground(String topColor, String bottomColor) {
int[] colors = {Color.parseColor(topColor), Color.parseColor(bottomColor)};
//create a new gradient color
GradientDrawable gd = new GradientDrawable(GradientDrawable.Orientation.BL_TR, colors);
gd.setShape(GradientDrawable.RECTANGLE);
gd.setCornerRadius(30f);
return gd;
}
This way, all corners are rounded. 这样,所有的角都是圆的。 I can't find a way to set the radius of only top corners.
我找不到设置仅顶部拐角半径的方法。 Ay ideas?
有想法吗?
I know similar question have been asked, but no solutions seems good in my case. 我知道有人问过类似的问题,但就我而言,没有任何解决方案看起来不错。
Thanks 谢谢
you can use setCornerRadii (float[] radii)
您可以使用
setCornerRadii (float[] radii)
You can supply radii for each of the 4 corners. 您可以为4个角的每个角提供半径。 For each corner, the array contains 2 values, [X_radius, Y_radius].
对于每个角,数组包含2个值,[X_radius,Y_radius]。 The corners are ordered top-left, top-right, bottom-right, bottom-left.
角按左上角,右上角,右下角,左下角的顺序排列。
gd.setCornerRadii(new float[] { 8, 8, 8, 8, 0, 0, 0, 0 });
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.