简单总结RectF、Rect 和Matrix ,还有Paint的使用方法
-
1、Rect类和RectF类
参考资料:http://byandby.iteye.com/blog/826230
管方文档:Rect 类: http://developer.android.com/reference/android/graphics/Rect.html
RectF类:http://developer.android.com/reference/android/graphics/RectF.htmlRectF和Rect都表示的是一个矩形的区域,他们的构造方法类似,详细请看官方文档,这里以RectF为例,如下:
RectF() :构造一个无参的矩形;RectF(float left,float top,float right,float bottom)构造一个指定了4个参数的矩形 ,这些参数都是坐标,即矩形的宽width = right - left ,高height = bottom - top;如下图所示
RectF rectF = new RectF(150,75,260,120);
150指的是矩形区域左上角的横坐标,即A;
75指的是矩形区域左上角的纵坐标,即B;
260指的是矩形区域右下角的横坐标,即C;
120指的是矩形区域右下角的纵坐标,即D;RectF(Rect F r)根据指定的RectF对象来构造一个RectF对象(对象的左边坐标不变) 。
RectF(Rect r)根据给定的Rect对象来构造一个RectF对象。
这就是RectF的功能了,Rect 也具有这个功能。两者的区别在于:
RectF 中的参数是单精度浮点型的;
Rect 中的参数是整形的。2、Matrix
参考资料:http://blog.163.com/lww2626@126/blog/static/27384067201192564628645http://www.cnblogs.com/plokmju/p/android_Matrix.html#MatrixRotate
http://blog.csdn.net/programchangesworld/article/details/49078387
3、Paint 画笔
参考资料:http://www.cnblogs.com/-OYK/archive/2011/10/25/2223624.html
-
参数官方API解释:
-
public RectF (float left, float top, float right, float bottom)
Added in API level 1Create a new rectangle with the specified coordinates. Note: no range checking is performed, so the caller must ensure that left <= right and top <= bottom.
Parameters
left The X coordinate of the left side of the rectangle top The Y coordinate of the top of the rectangle right The X coordinate of the right side of the rectangle bottom The Y coordinate of the bottom of the rectangle
-
百度翻译一下:
-
用指定坐标创建新矩形。注意:没有进行范围检查,所以调用者必须确保,左<=右和顶部<=底部。
-
左边矩形的x坐标
矩形顶部的y坐标
右边矩形的x坐标 -
矩形底部的y坐标
版权声明:本文为博主原创文章,未经博主允许不得转载。
更多相关文章
- android 坐标布局 AbsoluteLayout
- Android(安卓)自定义 View 理论基础
- Android(安卓)matrix偏移(平移),旋转,缩放,倾斜的原理
- 切换Activity时的动画overridePendingTransition(A,B)解析
- 十二、Android(安卓)UI开发专题
- 【自定义控件系列四】android绘制实战(一)通过Canvas+Path+Paint
- Android(安卓)屏幕(View)坐标系统
- android 自定义相机 取矩形内内容 注意事项
- Android高手进阶教程(三)之----Android(安卓)中自定义View的应用