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

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

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

Rect.set介绍

[英]Set the rectangle's coordinates to the specified values. Note: no range checking is performed, so it is up to the caller to ensure that left
[中]将矩形的坐标设置为指定的值。注意:不执行范围检查,因此由调用者确保

代码示例

代码示例来源:origin: bumptech/glide

@Override
 public void getItemOffsets(Rect outRect, View view, RecyclerView parent,
   RecyclerView.State state) {
  outRect.set(gridMargin, gridMargin, gridMargin, gridMargin);
 }
});

代码示例来源:origin: robolectric/robolectric

@Implementation
protected void getBoundsInScreen(Rect outBounds) {
 if (boundsInScreen == null) {
  outBounds.setEmpty();
 } else {
  outBounds.set(boundsInScreen);
 }
}

代码示例来源:origin: robolectric/robolectric

public void setGlobalVisibleRect(Rect rect) {
 if (rect != null) {
  globalVisibleRect = new Rect();
  globalVisibleRect.set(rect);
 } else {
  globalVisibleRect = null;
 }
}

代码示例来源:origin: PhilJay/MPAndroidChart

/**
 * calculates the approximate height of a text, depending on a demo text
 * avoid repeated calls (e.g. inside drawing methods)
 *
 * @param paint
 * @param demoText
 * @return
 */
public static int calcTextHeight(Paint paint, String demoText) {
  Rect r = mCalcTextHeightRect;
  r.set(0,0,0,0);
  paint.getTextBounds(demoText, 0, demoText.length(), r);
  return r.height();
}

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

@Nullable
@Override
public Object getElementToHighlightAtPosition(View element, int x, int y, Rect bounds) {
 bounds.set(0, 0, element.getWidth(), element.getHeight());
 return element;
}

代码示例来源:origin: google/ExoPlayer

private void update() {
 bufferedBar.set(progressBar);
 scrubberBar.set(progressBar);
 long newScrubberTime = scrubbing ? scrubPosition : position;
 if (duration > 0) {
  int bufferedPixelWidth = (int) ((progressBar.width() * bufferedPosition) / duration);
  bufferedBar.right = Math.min(progressBar.left + bufferedPixelWidth, progressBar.right);
  int scrubberPixelPosition = (int) ((progressBar.width() * newScrubberTime) / duration);
  scrubberBar.right = Math.min(progressBar.left + scrubberPixelPosition, progressBar.right);
 } else {
  bufferedBar.right = progressBar.left;
  scrubberBar.right = progressBar.left;
 }
 invalidate(seekBounds);
}

代码示例来源:origin: robolectric/robolectric

@Implementation
protected void getBoundsInScreen(Rect outBounds) {
 if (boundsInScreen == null) {
  boundsInScreen = new Rect();
 }
 outBounds.set(boundsInScreen);
}

代码示例来源:origin: robolectric/robolectric

@Implementation
protected void setBoundsInScreen(Rect b) {
 if (boundsInScreen == null) {
  boundsInScreen = new Rect(b);
 } else {
  boundsInScreen.set(b);
 }
}

代码示例来源:origin: robolectric/robolectric

@Implementation
protected void setBoundsInParent(Rect b) {
 if (boundsInParent == null) {
  boundsInParent = new Rect(b);
 } else {
  boundsInParent.set(b);
 }
}

代码示例来源:origin: robolectric/robolectric

static void ImageDecoder_nGetPadding(long nativePtr,
  Rect outPadding) {
 CppImageDecoder decoder = NATIVE_IMAGE_DECODER_REGISTRY.getNativeObject(nativePtr);
 // decoder.mPeeker.getPadding(outPadding);
 if (decoder.imgStream.isNinePatch()) {
  outPadding.set(0, 0, 0, 0);
 } else {
  outPadding.set(-1, -1, -1, -1);
 }
}

代码示例来源:origin: robolectric/robolectric

@Implementation
protected void getBoundsInParent(Rect outBounds) {
 if (boundsInParent == null) {
  boundsInParent = new Rect();
 }
 outBounds.set(boundsInParent);
}

代码示例来源:origin: koral--/android-gif-drawable

@Override
protected void onBoundsChange(Rect bounds) {
  mDstRect.set(bounds);
  if (mTransform != null) {
    mTransform.onBoundsChange(bounds);
  }
}

代码示例来源:origin: airbnb/lottie-android

@Override public void drawLayer(@NonNull Canvas canvas, Matrix parentMatrix, int parentAlpha) {
 Bitmap bitmap = getBitmap();
 if (bitmap == null || bitmap.isRecycled()) {
  return;
 }
 float density = Utils.dpScale();
 paint.setAlpha(parentAlpha);
 if (colorFilterAnimation != null) {
  paint.setColorFilter(colorFilterAnimation.getValue());
 }
 canvas.save();
 canvas.concat(parentMatrix);
 src.set(0, 0, bitmap.getWidth(), bitmap.getHeight());
 dst.set(0, 0, (int) (bitmap.getWidth() * density), (int) (bitmap.getHeight() * density));
 canvas.drawBitmap(bitmap, src, dst , paint);
 canvas.restore();
}

代码示例来源:origin: google/ExoPlayer

@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
 int width = right - left;
 int height = bottom - top;
 int barY = (height - touchTargetHeight) / 2;
 int seekLeft = getPaddingLeft();
 int seekRight = width - getPaddingRight();
 int progressY = barY + (touchTargetHeight - barHeight) / 2;
 seekBounds.set(seekLeft, barY, seekRight, barY + touchTargetHeight);
 progressBar.set(seekBounds.left + scrubberPadding, progressY,
   seekBounds.right - scrubberPadding, progressY + barHeight);
 update();
}

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

public void setExpandedBounds(int left, int top, int right, int bottom) {
  if (!rectEquals(mExpandedBounds, left, top, right, bottom)) {
    mExpandedBounds.set(left, top, right, bottom);
    mBoundsChanged = true;
    onBoundsChanged();
  }
}

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

public void setCollapsedBounds(int left, int top, int right, int bottom) {
  if (!rectEquals(mCollapsedBounds, left, top, right, bottom)) {
    mCollapsedBounds.set(left, top, right, bottom);
    mBoundsChanged = true;
    onBoundsChanged();
  }
}

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

public void setOffset(int offset) {
  offset = Math.max(minOffset, offset);
  if (offset != getTranslationY()) {
    setTranslationY(offset);
    imageOffset = (int) (offset * parallaxFactor);
    clipBounds.set(0, -offset, getWidth(), getHeight());
    setClipBounds(clipBounds);
    setScrimAlpha(Math.min(
        ((float) -offset / getMinimumHeight()) * maxScrimAlpha, maxScrimAlpha));
    postInvalidateOnAnimation();
  }
  setPinned(offset == minOffset);
}

代码示例来源:origin: robolectric/robolectric

@Test
public void setWithRectSetsCoordinates() {
 Rect rSrc = new Rect(1, 2, 3, 4);
 Rect r = new Rect();
 r.set(rSrc);
 assertThat(r.left).isEqualTo(1);
 assertThat(r.top).isEqualTo(2);
 assertThat(r.right).isEqualTo(3);
 assertThat(r.bottom).isEqualTo(4);
}

代码示例来源:origin: robolectric/robolectric

@Test
public void setWithIntsSetsCoordinates() {
 Rect r = new Rect();
 r.set(1, 2, 3, 4);
 assertThat(r.left).isEqualTo(1);
 assertThat(r.top).isEqualTo(2);
 assertThat(r.right).isEqualTo(3);
 assertThat(r.bottom).isEqualTo(4);
}

相关文章