The difference and connection between Rect and RECTF in Android
1. Contact:
are used to represent a rectangular area in a coordinate system, and can do some simple things about it. This rectangular area needs to be represented by the top left and bottom two coordinate points.
2. Difference:
(1). Accuracy is not the same. A rect is a numeric value using the type int, and RECTF is using the float type as a numeric value.
(2). The methods provided by the two types are also not fully consistent.
3. Code section
PackageCom.pansoft.viewdemo.view;ImportAndroid.content.Context;ImportAndroid.graphics.Canvas;ImportAndroid.graphics.Color;ImportAndroid.graphics.Paint;ImportAndroid.graphics.Paint.Style;ImportAndroid.graphics.Rect;ImportAndroid.graphics.RectF;ImportAndroid.view.View;/** Custom view**/ Public class MyView extends View { /** Context * / PrivateContext Mcontext;/** Brush * / PrivatePaint Mpaint; Public MyView(Context context) {Super(context); Mcontext = context; }@Override protected void OnDraw(Canvas canvas) {Super. OnDraw (canvas); Mpaint =NewPaint ();//Set the color of the brushMpaint.setcolor (color.red);//Set Fill colorMpaint.setstyle (Style.fill); RECTF rect =NewRECTF (Ten,Ten, -, -);//Rect rect2 = new Rect (ten, ten, +);Canvas.drawrect (rect, mpaint); }}
The difference and connection between Rect and RECTF in Android