canvas.drawRoundRect步骤,绘制圆角矩形
发布时间:2010-05-30 00:06:39 文章来源:www.iduyao.cn 采编人员:星星草
canvas.drawRoundRect方法,绘制圆角矩形
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);
}
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。
其他相似内容:
-
【IOS】高仿糗事百科客户端(基本实现了除注册,评论之外的功能)
【原创作品, 欢迎转载,转载请在明显处注明! 谢谢。
原文地址:h...
-
数独游戏(1)之绘制九宫格,并初始化数据
<数独游戏>之绘制九宫格,并初始化数据
1.在工程里的res/values目录下新建一个colors....
-
关于listview的setAdapter和notifyDataSetChanged
做了个需要更新listview的项目,在listview更新时遇到问题,抓耳挠腮半天仍未能解...
-
最完整的让cocos2d游戏适配IPAD Retina的教程
暂时在网上还没找到一个让cocos2d开发的IPhone游戏快速地适应IPAD2 Retina模式的教...
-
使用ContentObserver监听ContentProvider中数据的变化
如果ContentProvider的访问者需要知道ContentProvider中的数据发生了变化,...
-
Andriod 实现可拖动列表
在做一个应用时,有一个需求,需要实现像iphone天气的城市列表界面的可拖动功能。其实android已...
-
类似APP大厅程序的实现
由于Android可以按照一定的规则,启动另外一个应用程序的Activity,并可以传递一些数据,因此下面的需求,在原则...
-
编写小程序查看CSDN博客信息(ASIHTTPRequest+TFHpple)
作为一个iOS练习,使用ASIHTTPRequest+TFHpple写了个小程序读取CSDN博客...
-
Objective-C中nil与release的区别与用法
做IOS开发的估计都对Objective-C的内存管理机制很头疼,一不小心程序就会出内存泄露...
-
联想抗衡苹果之路:用苹果的方式打败苹果?
联想教父柳传志说过,联想历史上曾经历三次生死危机,但都死里逃生,并一次次验证着“大难不...