android.view.View.getDrawingRect()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(316)

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

View.getDrawingRect介绍

暂无

代码示例

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

Rect outRect = new Rect();
 int[] location = new int[2];
 private boolean isViewInBounds(View view, int x, int y){
   view.getDrawingRect(outRect);
   view.getLocationOnScreen(location);
   outRect.offset(location[0], location[1]);
   return outRect.contains(x, y);
 }

代码示例来源:origin: xfumihiro/ViewInspector

public static void drawMeasures(View view, Canvas canvas, Integer measureCount) {
 final int color;
 switch (measureCount) {
  case 0:
  case 1:
   color = NO_OVERMEASURE;
   break;
  case 2:
   color = OVERMEASURE_1x;
   break;
  case 3:
   color = OVERMEASURE_2x;
   break;
  case 4:
   color = OVERMEASURE_3x;
   break;
  default:
   color = OVERMEASURE_4x;
   break;
 }
 if (measureCount > 1) {
  final int tintColor =
    Color.argb(150, Color.red(color), Color.green(color), Color.blue(color));
  Rect rect = new Rect();
  view.getDrawingRect(rect);
  Paint paint = new Paint();
  paint.setColor(tintColor);
  canvas.drawRect(rect, paint);
 }
}

代码示例来源:origin: jdamcd/android-crop

} else {
  Rect viewDrawingRect = new Rect();
  viewContext.getDrawingRect(viewDrawingRect);

代码示例来源:origin: Dimezis/BlurView

/**
 * setup matrix to draw starting from blurView's position
 */
private void setupInternalCanvasMatrix() {
  blurView.getDrawingRect(relativeViewBounds);
  if (shouldTryToOffsetCoords) {
    try {
      rootView.offsetDescendantRectToMyCoords(blurView, relativeViewBounds);
    } catch (IllegalArgumentException e) {
      // BlurView is not a child of the rootView (i.e. it's in Dialog)
      // Fallback to regular coordinates system
      shouldTryToOffsetCoords = false;
    }
  } else {
    blurView.getLocationInWindow(locationInWindow);
    relativeViewBounds.offset(locationInWindow[0], locationInWindow[1]);
  }
  float scaleFactorX = scaleFactor * roundingWidthScaleFactor;
  float scaleFactorY = scaleFactor * roundingHeightScaleFactor;
  float scaledLeftPosition = -relativeViewBounds.left / scaleFactorX;
  float scaledTopPosition = -relativeViewBounds.top / scaleFactorY;
  float scaledTranslationX = blurView.getTranslationX() / scaleFactorX;
  float scaledTranslationY = blurView.getTranslationY() / scaleFactorY;
  internalCanvas.translate(scaledLeftPosition - scaledTranslationX, scaledTopPosition - scaledTranslationY);
  internalCanvas.scale(1f / scaleFactorX, 1f / scaleFactorY);
}

代码示例来源:origin: chentao0707/SimplifyReader

other.getDrawingRect(otherRect);
offsetDescendantRectToMyCoords(other, otherRect);
int distance = getDistance(previouslyFocusedRect, otherRect, direction);

代码示例来源:origin: burhanrashid52/PhotoEditor

private boolean isViewInBounds(View view, int x, int y) {
  view.getDrawingRect(outRect);
  view.getLocationOnScreen(location);
  outRect.offset(location[0], location[1]);
  return outRect.contains(x, y);
}

代码示例来源:origin: eneim/toro

/** Mimic {@link ToroUtil#visibleAreaOffset(ToroPlayer, ViewParent)} */
private static float visibleAreaOffset(@NonNull View playerView) {
 Rect drawRect = new Rect();
 playerView.getDrawingRect(drawRect);
 int drawArea = drawRect.width() * drawRect.height();
 Rect playerRect = new Rect();
 boolean visible = playerView.getGlobalVisibleRect(playerRect, new Point());
 float offset = 0.f;
 if (visible && drawArea > 0) {
  int visibleArea = playerRect.height() * playerRect.width();
  offset = visibleArea / (float) drawArea;
 }
 return offset;
}

代码示例来源:origin: multidots/android-app-common-tasks

} else {
  Rect viewDrawingRect = new Rect();
  mContext.getDrawingRect(viewDrawingRect);
  if (mCircle) {

代码示例来源:origin: multidots/android-app-common-tasks

} else {
  Rect viewDrawingRect = new Rect();
  mContext.getDrawingRect(viewDrawingRect);
  if (mCircle) {

代码示例来源:origin: moagrius/TileView

private void scrollToChild(View child) {
 child.getDrawingRect(mTempRect);
 offsetDescendantRectToMyCoords(child, mTempRect);
 int deltaX = computeScrollXDeltaToGetChildRectOnScreen(mTempRect);
 int deltaY = computeScrollYDeltaToGetChildRectOnScreen(mTempRect);
 if (deltaY != 0 || deltaX != 0) {
  scrollBy(deltaX, deltaY);
 }
}

代码示例来源:origin: moagrius/TileView

private boolean isWithinDeltaOfScreen(View descendant, int delta, int width, int height) {
 descendant.getDrawingRect(mTempRect);
 offsetDescendantRectToMyCoords(descendant, mTempRect);
 return ((mTempRect.bottom + delta) >= getScrollY() && (mTempRect.top - delta) <= (getScrollY() + height))
   && ((mTempRect.right + delta) >= getScrollX() && (mTempRect.left - delta) <= (getScrollX() + width));
}

代码示例来源:origin: moagrius/TileView

@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
 super.onSizeChanged(w, h, oldw, oldh);
 View currentFocused = findFocus();
 if (null == currentFocused || this == currentFocused) {
  return;
 }
 if (isWithinDeltaOfScreen(currentFocused, 0, oldw, oldh)) {
  currentFocused.getDrawingRect(mTempRect);
  offsetDescendantRectToMyCoords(currentFocused, mTempRect);
  int deltaX = computeScrollXDeltaToGetChildRectOnScreen(mTempRect);
  int deltaY = computeScrollYDeltaToGetChildRectOnScreen(mTempRect);
  performScrollBy(deltaX, deltaY);
 }
}

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

private boolean inViewBounds(View view, int x, int y){
  view.getDrawingRect(outRect);
  view.getLocationOnScreen(location);
  outRect.offset(location[0], location[1]);
  return outRect.contains(x, y);
}

代码示例来源:origin: fookwood/Launcher3

@Override
public void requestChildFocus(View child, View focused) {
  super.requestChildFocus(child, focused);
  if (child != null) {
    Rect r = new Rect();
    child.getDrawingRect(r);
    requestRectangleOnScreen(r);
  }
}

代码示例来源:origin: klinker24/launcher3

@Override
public void requestChildFocus(View child, View focused) {
  super.requestChildFocus(child, focused);
  if (child != null) {
    Rect r = new Rect();
    child.getDrawingRect(r);
    requestRectangleOnScreen(r);
  }
}

代码示例来源:origin: klinker24/Android-Blur-Launcher

@Override
public void requestChildFocus(View child, View focused) {
  super.requestChildFocus(child, focused);
  if (child != null) {
    Rect r = new Rect();
    child.getDrawingRect(r);
    requestRectangleOnScreen(r);
  }
}

代码示例来源:origin: enricocid/LaunchEnr

@Override
public void requestChildFocus(View child, View focused) {
  super.requestChildFocus(child, focused);
  if (child != null) {
    Rect r = new Rect();
    child.getDrawingRect(r);
    requestRectangleOnScreen(r);
  }
}

代码示例来源:origin: wealthfront/magellan

private int[] getCenterClickedView(ViewGroup from) {
 Rect clickedViewRect = new Rect();
 clickedView.getDrawingRect(clickedViewRect);
 from.offsetDescendantRectToMyCoords(clickedView, clickedViewRect);
 return new int[] {(int) clickedViewRect.exactCenterX(), (int) clickedViewRect.exactCenterY()};
}

代码示例来源:origin: apptentive/apptentive-android

/**
 * @return whether the descendant of this scroll view is within delta
 *  pixels of being on the screen.
 */
private boolean isWithinDeltaOfScreen(View descendant, int delta, int height) {
  descendant.getDrawingRect(mTempRect);
  offsetDescendantRectToMyCoords(descendant, mTempRect);
  return (mTempRect.bottom + delta) >= getScrollY()
      && (mTempRect.top - delta) <= (getScrollY() + height);
}

代码示例来源:origin: TheMelody/LotteryTrend

/**
 * @return whether the descendant of this scroll view is within delta pixels
 *         of being on the screen.
 */
private boolean isWithinDeltaOfScreenV(View descendant, int delta,
    int height) {
  descendant.getDrawingRect(mTempRect);
  offsetDescendantRectToMyCoords(descendant, mTempRect);
  return (mTempRect.bottom + delta) >= getScrollY()
      && (mTempRect.top - delta) <= (getScrollY() + height);
}

相关文章

微信公众号

最新文章

更多

View类方法