public void drawRoundRect (RectF rect, float rx, float ry, Paint paint)
Draw the specified round-rect using the specified paint. The roundrect will be filled or framed based on the Style in the paint.


Parameters
rect The rectangular bounds of the roundRect to be drawn
rx The x-radius of the oval used to round the corners
ry The y-radius of the oval used to round the corners
paint The paint used to draw the roundRect


【功能说明】该方法用于在画布上绘制圆角矩形,通过指定RectF对象以及圆角半径来实现。该方法是绘制圆角矩形的主要方法,同时也可以通过设置画笔的空心效果来绘制空心的圆角矩形。
【基本语法】public void drawRoundRect (RectF rect, float rx, float ry, Paint paint)
参数说明
rect:RectF对象。
rx:x方向上的圆角半径。
ry:y方向上的圆角半径。
paint:绘制时所使用的画笔。


protected void onDraw(Canvas canvas) {
// TODO Auto-generated method stub
super.onDraw(canvas);
//新建一只画笔,并设置为绿色属性
Paint _paint = new Paint();
_paint.setColor(Color.GREEN);
//新建矩形r1
RectF r1 = new RectF();
r1.left = 50;
r1.right = 250;
r1.top = 50 ;
r1.bottom = 150;

//新建矩形r2
RectF r2 = new RectF();
r2.left = 50;
r2.right = 250;
r2.top = 200 ;
r2.bottom = 300;

//画出矩形r1
canvas.drawRect(r1, _paint);
//画出圆角矩形r2
_paint.setColor(Color.rgb(204, 204, 204));
canvas.drawRoundRect(r2, 10, 10, _paint);


}

更多相关文章

  1. Android(安卓)View绘制机制
  2. PointerLocationView 源码分析
  3. Android折线图
  4. Android折线图
  5. Android图形显示系统——下层显示4:图层合成上(合成原理与3D合成)
  6. Android(安卓)EditText 设置圆角
  7. Android通过onDraw实现在View中绘图操作
  8. RecyclerView正确打开分隔符
  9. a64_7.1-v3.1android拉伸绘制矩形区域距离默认平板外边界问题

随机推荐

  1. Android(安卓)设置TextView自动调整字体
  2. 关于Android(安卓)Studio升级到3.4.2版本
  3. Android(安卓)输入分析
  4. android:onClick详解
  5. Android发送信息模拟系统
  6. Android(安卓)Service 解析(1)
  7. AIDL通信 android 在5.0以使用隐式Intent
  8. Android(安卓)曲线图的绘制示例代码
  9. android 点击EditText 弹出日期选择器Dat
  10. Android(安卓)数据库基本操作-2