tou*_*doy 4 android android-canvas android-graphics android-paint
我正在通过扩展创建自定义视图 android.view.View.
现在,我需要在低于 21 的 API 级别上绘制一个圆角矩形。Android 有一个内置的方法名称drawRoundRect(float left, float top, float right, float bottom, float rx, float ry, Paint paint)in android.graphics.Canvas,但它不支持低于 21 的 API,但我需要在 API 16 上绘制它。我怎样才能做到这一点?
提前致谢
tou*_*doy 10
毕竟我得到了我的解决方案!
虽然drawRoundRect(float left, float top, float right, float bottom, float rx, float ry, Paint paint)是在API level 21中添加的,但是还有另外一种方法,drawRect (RectF rect,Paint paint)是在API level 1中添加的,可以替代使用。
感谢pskink的指导。
例子:
Rectf rectf= new Rectf(left, top, right, bottom);
canvas.drawRoundRect(rectf,rx,ry, mPaint);
Run Code Online (Sandbox Code Playgroud)