本文整理了Java中android.graphics.Rect.<init>
方法的一些代码示例,展示了Rect.<init>
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Rect.<init>
方法的具体详情如下:
包路径:android.graphics.Rect
类名称:Rect
方法名:<init>
[英]Create a new empty Rect. All coordinates are initialized to 0.
[中]创建一个新的空矩形。所有坐标都初始化为0。
代码示例来源:origin: stackoverflow.com
Rect bounds = new Rect();
Paint textPaint = textView.getPaint();
textPaint.getTextBounds(text, 0, text.length(), bounds);
int height = bounds.height();
int width = bounds.width();
代码示例来源:origin: chrisjenx/Calligraphy
private void init() {
paint = new Paint();
paint.setTextSize(50);
textBounds = new Rect();
}
代码示例来源:origin: seven332/EhViewer
public BatteryDrawable() {
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
mPaint.setStyle(Paint.Style.FILL);
mTopRect = new Rect();
mBottomRect = new Rect();
mRightRect = new Rect();
mHeadRect = new Rect();
mElectRect = new Rect();
updatePaint();
}
代码示例来源:origin: stackoverflow.com
Paint paint = new Paint();
Rect r = new Rect(10, 10, 200, 100);
@Override
public void onDraw(Canvas canvas) {
// fill
paint.setStyle(Paint.Style.FILL);
paint.setColor(Color.MAGENTA);
canvas.drawRect(r, paint);
// border
paint.setStyle(Paint.Style.STROKE);
paint.setColor(Color.BLACK);
canvas.drawRect(r, paint);
}
代码示例来源:origin: smuyyh/BookReader
private void init() {
mPaintText = new Paint(Paint.ANTI_ALIAS_FLAG);
mPaintText.setColor(Color.WHITE);
mPaintBackground = new Paint(Paint.ANTI_ALIAS_FLAG);
mRect = new Rect();
}
代码示例来源:origin: Rukey7/MvpApp
private Bitmap getCircleBitmap(final int radius) {
final Bitmap output = Bitmap.createBitmap(originBitmap.getWidth(), originBitmap.getHeight(), Bitmap.Config.ARGB_8888);
final Canvas canvas = new Canvas(output);
final Paint paint = new Paint();
final Rect rect = new Rect((int) (x - radius), (int) (y - radius), (int) (x + radius), (int) (y + radius));
paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
canvas.drawCircle(x, y, radius, paint);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
canvas.drawBitmap(originBitmap, rect, rect, paint);
return output;
}
代码示例来源:origin: GitLqr/LQRWeChat
mPaint.setStyle(Paint.Style.FILL);
mPaint.setColor(Color.parseColor("#70000000"));// 半透明
Rect shadowRect = null;
if (mArrowLocation == LOCATION_LEFT) {
shadowRect = new Rect(mArrowWidth, 0, getWidth(), getHeight() - getHeight()
* percent / 100);//阴影的宽度(图片的宽度)为ImageView的宽度减去箭头的宽度
} else {
shadowRect = new Rect(0, 0, getWidth() - mArrowWidth, getHeight() - getHeight()
* percent / 100);//阴影的宽度(图片的宽度)为ImageView的宽度减去箭头的宽度
mPaint.setColor(Color.parseColor("#FFFFFF"));
mPaint.setStrokeWidth(2);
int marginLeft = 0;//文字的左边距
if (mArrowLocation == LOCATION_LEFT) {//如果是向左的
rect = new Rect(mArrowWidth, 0, 0, 0);
marginLeft = (getWidth() - mArrowWidth) / 2;
} else {
rect = new Rect(mArrowWidth, 0, 0, 0);
marginLeft = getWidth() / 2 - mArrowWidth;
代码示例来源:origin: yipianfengye/android-zxingLibrary
/**
* 绘制移动扫描线
*
* @param canvas
* @param frame
*/
private void drawScanLight(Canvas canvas, Rect frame) {
if (scanLineTop == 0) {
scanLineTop = frame.top;
}
if (scanLineTop >= frame.bottom - 30) {
scanLineTop = frame.top;
} else {
scanLineTop += SCAN_VELOCITY;
}
Rect scanRect = new Rect(frame.left, scanLineTop, frame.right,
scanLineTop + 30);
canvas.drawBitmap(scanLight, null, scanRect, paint);
}
代码示例来源:origin: rey5137/material
private void measureBaseSize(){
mPaint.setTextSize(mTextSize);
mPaint.setTypeface(mTypeface);
mDayBaseWidth = mPaint.measureText("88", 0, 2) + mDayPadding * 2;
Rect bounds = new Rect();
mPaint.getTextBounds("88", 0, 2 ,bounds);
mDayBaseHeight = bounds.height();
}
代码示例来源:origin: Bigkoo/Android-PickerView
private void measuredOutContentStart(String content) {
Rect rect = new Rect();
paintOuterText.getTextBounds(content, 0, content.length(), rect);
switch (mGravity) {
case Gravity.CENTER:
if (isOptions || label == null || label.equals("") || !isCenterLabel) {
drawOutContentStart = (int) ((measuredWidth - rect.width()) * 0.5);
} else {//只显示中间label时,时间选择器内容偏左一点,留出空间绘制单位标签
drawOutContentStart = (int) ((measuredWidth - rect.width()) * 0.25);
}
break;
case Gravity.LEFT:
drawOutContentStart = 0;
break;
case Gravity.RIGHT:
drawOutContentStart = measuredWidth - rect.width() - (int) CENTER_CONTENT_OFFSET;
break;
}
}
代码示例来源:origin: vondear/RxTool
/**
* 绘制上面的文字和下面的比例尺,因为比例尺是.9.png,
* 我们需要利用drawNinepath方法绘制比例尺
*/
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
int width = scaleWidth;
mPaint.setColor(textColor);
mPaint.setAntiAlias(true);
mPaint.setTextSize(textSize);
mPaint.setTypeface(Typeface.DEFAULT_BOLD);
float textWidth = mPaint.measureText(text);
canvas.drawText(text, (width - textWidth) / 2, textSize, mPaint);
Rect scaleRect = new Rect(0, textSize + scaleSpaceText, width, textSize + scaleSpaceText + scaleHeight);
drawNinepath(canvas, R.drawable.plotting_scale_new, scaleRect);
}
代码示例来源:origin: stackoverflow.com
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.LINEAR_TEXT_FLAG);
paint.setStyle(Paint.Style.FILL);
paint.setColor(color);
paint.setTextAlign(Paint.Align.CENTER);
paint.setTextSize(textSize);
Rect bounds = new Rect();
paint.getTextBounds("a", 0, 1, bounds);
buffer.drawText(this.myText, canvasWidht >> 1, (canvasHeight + bounds.height()) >> 1, paint);
// remember x >> 1 is equivalent to x / 2, but works much much faster
代码示例来源:origin: seven332/EhViewer
private void init(Context context, AttributeSet attrs) {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DividerView);
int color = a.getColor(R.styleable.DividerView_dividerColor, Color.BLACK);
mDividerWidth = a.getDimensionPixelOffset(R.styleable.DividerView_dividerWidth, 0);
mDividerHeight = a.getDimensionPixelOffset(R.styleable.DividerView_dividerHeight, 0);
a.recycle();
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
mPaint.setColor(color);
mRect = new Rect();
}
代码示例来源:origin: stackoverflow.com
Point displaySize = new Point();
activity.getWindowManager().getDefaultDisplay().getRealSize(displaySize);
Rect windowSize = new Rect();
ctivity.getWindow().getDecorView().getWindowVisibleDisplayFrame(windowSize);
int width = displaySize.x - Math.abs(windowSize.width());
int height = displaySize.y - Math.abs(windowSize.height());
return new Point(width, height);
代码示例来源:origin: castorflex/SmoothProgressBar
public interface Callbacks {
public void onStop();
public void onStart();
}
代码示例来源:origin: joyoyao/superCleanMaster
private Bitmap getCircleBitmap(final int radius) {
final Bitmap output = Bitmap.createBitmap(originBitmap.getWidth(), originBitmap.getHeight(), Bitmap.Config.ARGB_8888);
final Canvas canvas = new Canvas(output);
final Paint paint = new Paint();
final Rect rect = new Rect((int) (x - radius), (int) (y - radius), (int) (x + radius), (int) (y + radius));
paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
canvas.drawCircle(x, y, radius, paint);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
canvas.drawBitmap(originBitmap, rect, rect, paint);
return output;
}
}
代码示例来源:origin: code-mc/loadtoast
public LoadToastView(Context context) {
super(context);
textPaint.setTextSize(15);
textPaint.setColor(Color.BLACK);
textPaint.setAntiAlias(true);
backPaint.setColor(Color.WHITE);
backPaint.setAntiAlias(true);
iconBackPaint.setColor(Color.BLUE);
iconBackPaint.setAntiAlias(true);
loaderPaint.setAntiAlias(true);
loaderPaint.setColor(fetchPrimaryColor());
loaderPaint.setStyle(Paint.Style.STROKE);
borderPaint.setColor(Color.TRANSPARENT);
borderPaint.setStyle(Paint.Style.STROKE);
successPaint.setColor(getResources().getColor(R.color.color_success));
iconBounds = new Rect(TOAST_HEIGHT + MAX_TEXT_WIDTH - padding, padding, TOAST_HEIGHT + MAX_TEXT_WIDTH - padding + IMAGE_WIDTH, IMAGE_WIDTH + padding);
代码示例来源:origin: googlesamples/android-vision
/**
* Draws the bitmap background, scaled to the device size. Returns the scale for future use in
* positioning the facial landmark graphics.
*/
private double drawBitmap(Canvas canvas) {
double viewWidth = canvas.getWidth();
double viewHeight = canvas.getHeight();
double imageWidth = mBitmap.getWidth();
double imageHeight = mBitmap.getHeight();
double scale = Math.min(viewWidth / imageWidth, viewHeight / imageHeight);
Rect destBounds = new Rect(0, 0, (int)(imageWidth * scale), (int)(imageHeight * scale));
canvas.drawBitmap(mBitmap, null, destBounds, null);
return scale;
}
代码示例来源:origin: stackoverflow.com
Rect bounds = new Rect();
Paint paint = new Paint();
paint.setTextAlign(Align.LEFT);
paint.setTypeface(typeface);
paint.setTextSize(textSize);
paint.getTextBounds(text, 0, text.length(), bounds);
代码示例来源:origin: eleme/UETool
protected float getTextHeight(String text) {
Rect rect = new Rect();
textPaint.getTextBounds(text, 0, text.length(), rect);
return rect.height();
}
内容来源于网络,如有侵权,请联系作者删除!