I am creating a custom view by extending android.view.View
.
Now, I need to draw a rounded rectangle on API level below 21. Android has a built in method name,drawRoundRect(float left, float top, float right, float bottom, float rx, float ry, Paint paint)
in android.graphics.Canvas
, but It doesn't support API below 21, but I need to draw this on API 16. How can I achieve that?
Thanks in advance
I got my solution after all!
Although drawRoundRect(float left, float top, float right, float bottom, float rx, float ry, Paint paint)
is added in API level 21, there is another method, drawRect (RectF rect,Paint paint)
which is added in API level 1 that can be used instead.
Thanks pskink for the guide.
Example:
Rectf rectf= new Rectf(left, top, right, bottom);
canvas.drawRoundRect(rectf,rx,ry, mPaint);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With