android.graphics.Rect.height()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(165)

本文整理了Java中android.graphics.Rect.height方法的一些代码示例,展示了Rect.height的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Rect.height方法的具体详情如下:
包路径:android.graphics.Rect
类名称:Rect
方法名:height

Rect.height介绍

暂无

代码示例

代码示例来源:origin: nickbutcher/plaid

private void onBoundsChanged() {
  mDrawTitle = mCollapsedBounds.width() > 0 && mCollapsedBounds.height() > 0
      && mExpandedBounds.width() > 0 && mExpandedBounds.height() > 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: 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: 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: facebook/litho

private boolean animatingRootBoundsFromZero(Rect currentVisibleArea) {
 return !mHasMounted
   && ((mRootHeightAnimation != null && currentVisibleArea.height() == 0)
     || (mRootWidthAnimation != null && currentVisibleArea.width() == 0));
}

代码示例来源: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: stackoverflow.com

private Rect r = new Rect();

private void drawCenter(Canvas canvas, Paint paint, String text) {
  canvas.getClipBounds(r);
  int cHeight = r.height();
  int cWidth = r.width();
  paint.setTextAlign(Paint.Align.LEFT);
  paint.getTextBounds(text, 0, text.length(), r);
  float x = cWidth / 2f - r.width() / 2f - r.left;
  float y = cHeight / 2f + r.height() / 2f - r.bottom;
  canvas.drawText(text, x, y, paint);
}

代码示例来源:origin: davemorrissey/subsampling-scale-image-view

private void setInvariants() {
  if (this.sRegion != null) {
    this.tile = true;
    this.sWidth = this.sRegion.width();
    this.sHeight = this.sRegion.height();
  }
}

代码示例来源:origin: eleme/UETool

protected float getTextHeight(String text) {
  Rect rect = new Rect();
  textPaint.getTextBounds(text, 0, text.length(), rect);
  return rect.height();
}

代码示例来源: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: PhilJay/MPAndroidChart

/**
 * calculates the approximate size of a text, depending on a demo text
 * avoid repeated calls (e.g. inside drawing methods)
 *
 * @param paint
 * @param demoText
 * @param outputFSize An output variable, modified by the function.
 */
public static void calcTextSize(Paint paint, String demoText, FSize outputFSize) {
  Rect r = mCalcTextSizeRect;
  r.set(0,0,0,0);
  paint.getTextBounds(demoText, 0, demoText.length(), r);
  outputFSize.width = r.width();
  outputFSize.height = r.height();
}

代码示例来源:origin: wangdan/AisenWeiBo

public static int getAppHeight(Activity paramActivity) {
  Rect localRect = new Rect();
  paramActivity.getWindow().getDecorView().getWindowVisibleDisplayFrame(localRect);
  return localRect.height();
}

代码示例来源:origin: stackoverflow.com

Rect rectf = new Rect();
<imageView>or<view>.getLocalVisibleRect(rectf);

Log.d("WIDTH        :", String.valueOf(rectf.width()));
Log.d("HEIGHT       :", String.valueOf(rectf.height()));
Log.d("left         :", String.valueOf(rectf.left));
Log.d("right        :", String.valueOf(rectf.right));
Log.d("top          :", String.valueOf(rectf.top));
Log.d("bottom       :", String.valueOf(rectf.bottom));

代码示例来源:origin: ArthurHub/Android-Image-Cropper

/**
 * Fix the given rectangle if it doesn't confirm to aspect ration rule.<br>
 * Make sure that width and height are equal if 1:1 fixed aspect ratio is requested.
 */
private static void fixRectForAspectRatio(Rect rect, int aspectRatioX, int aspectRatioY) {
 if (aspectRatioX == aspectRatioY && rect.width() != rect.height()) {
  if (rect.height() > rect.width()) {
   rect.bottom -= rect.height() - rect.width();
  } else {
   rect.right -= rect.width() - rect.height();
  }
 }
}

代码示例来源:origin: stackoverflow.com

Rect bounds = new Rect();
void drawString(Canvas canvas, Paint paint, String str, int x, int y) {
  String[] lines = str.split("\n");

  int yoff = 0;
  for (int i = 0; i < lines.length; ++i) {
    canvas.drawText(lines[i], x, y + yoff, paint);
    paint.getTextBounds(lines[i], 0, lines[i].length(), bounds);
    yoff += bounds.height();
  }
}

代码示例来源:origin: stackoverflow.com

Paint paint = new Paint();
Rect bounds = new Rect();

int text_height = 0;
int text_width = 0;

paint.setTypeface(Typeface.DEFAULT);// your preference here
paint.setTextSize(25);// have this the same as your text size

String text = "Some random text";

paint.getTextBounds(text, 0, text.length(), bounds);

text_height =  bounds.height();
text_width =  bounds.width();

代码示例来源:origin: alexvasilkov/GestureViews

private void calculateOutsideBounds(RectF area, Rect pos) {
  bounds.left = area.left - pos.width();
  bounds.right = area.right;
  bounds.top = area.top - pos.height();
  bounds.bottom = area.bottom;
}

代码示例来源:origin: rey5137/material

private void measureTimeText(){
  if(!mLocationDirty)
    return;
  mPaint.setTextSize(mTextTimeSize);
  Rect bounds = new Rect();
  mPaint.getTextBounds(BASE_TEXT, 0, BASE_TEXT.length(), bounds);
  mBaseHeight = bounds.height();
  mBaseY = (mHeaderRealHeight + mBaseHeight) / 2f;
  float dividerWidth = mPaint.measureText(TIME_DIVIDER, 0, TIME_DIVIDER.length());
  mHourWidth = mPaint.measureText(mHour, 0, mHour.length());
  mMinuteWidth = mPaint.measureText(mMinute, 0, mMinute.length());
  mDividerX = (mHeaderRealWidth - dividerWidth) / 2f;
  mHourX = mDividerX - mHourWidth;
  mMinuteX = mDividerX + dividerWidth;
  mMiddayX = mMinuteX + mMinuteWidth;
  mLocationDirty = false;
}

代码示例来源:origin: naman14/Timber

private BitmapDrawable createFloatingBitmap(View v) {
  floatingItemStatingBounds = new Rect(v.getLeft(), v.getTop(), v.getRight(), v.getBottom());
  floatingItemBounds = new Rect(floatingItemStatingBounds);
  Bitmap bitmap = Bitmap.createBitmap(floatingItemStatingBounds.width(),
      floatingItemStatingBounds.height(), Bitmap.Config.ARGB_8888);
  Canvas canvas = new Canvas(bitmap);
  v.draw(canvas);
  BitmapDrawable retDrawable = new BitmapDrawable(v.getResources(), bitmap);
  retDrawable.setBounds(floatingItemBounds);
  return retDrawable;
}

代码示例来源:origin: ankidroid/Anki-Android

public RectangleWrap(Rect rect) {
  super();
  this.x = rect.left;
  this.y = rect.top;
  this.height = rect.height();
  this.width = rect.width();
}

相关文章