下面列出了android.graphics.Rect#scale ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Calculates the snapshot frame in window coordinate space from crop.
*
* @param crop rect that is in snapshot coordinate space.
*/
@VisibleForTesting
Rect calculateSnapshotFrame(Rect crop) {
final Rect frame = new Rect(crop);
final float scale = mSnapshot.getScale();
// Rescale the frame from snapshot to window coordinate space
frame.scale(1 / scale);
// By default, offset it to to top/left corner
frame.offsetTo((int) (-crop.left / scale), (int) (-crop.top / scale));
// However, we also need to make space for the navigation bar on the left side.
final int colorViewLeftInset = getColorViewLeftInset(mStableInsets.left,
mContentInsets.left);
frame.offset(colorViewLeftInset, 0);
return frame;
}
public void getMagnifiedFrameInContentCoordsLocked(Rect rect) {
MagnificationSpec spec = mMagnificationSpec;
mMagnificationRegion.getBounds(rect);
rect.offset((int) -spec.offsetX, (int) -spec.offsetY);
rect.scale(1.0f / spec.scale);
}
/**
* Translate the screen rect to the application frame.
*/
public void translateRectInScreenToAppWinFrame(Rect rect) {
rect.scale(applicationInvertedScale);
}
/**
* Translate a Rect in application's window to screen.
*/
public void translateRectInAppWindowToScreen(Rect rect) {
rect.scale(applicationScale);
}
/**
* Translate a Rect in screen coordinates into the app window's coordinates.
*/
public void translateRectInScreenToAppWindow(Rect rect) {
rect.scale(applicationInvertedScale);
}
private AccessibilityNodeInfo createAccessibilityNodeInfoForNumberPicker(int left, int top,
int right, int bottom) {
AccessibilityNodeInfo info = AccessibilityNodeInfo.obtain();
info.setClassName(NumberPicker.class.getName());
info.setPackageName(mContext.getPackageName());
info.setSource(NumberPicker.this);
if (hasVirtualDecrementButton()) {
info.addChild(NumberPicker.this, VIRTUAL_VIEW_ID_DECREMENT);
}
info.addChild(NumberPicker.this, VIRTUAL_VIEW_ID_INPUT);
if (hasVirtualIncrementButton()) {
info.addChild(NumberPicker.this, VIRTUAL_VIEW_ID_INCREMENT);
}
info.setParent((View) getParentForAccessibility());
info.setEnabled(NumberPicker.this.isEnabled());
info.setScrollable(true);
final float applicationScale =
getContext().getResources().getCompatibilityInfo().applicationScale;
Rect boundsInParent = mTempRect;
boundsInParent.set(left, top, right, bottom);
boundsInParent.scale(applicationScale);
info.setBoundsInParent(boundsInParent);
info.setVisibleToUser(isVisibleToUser());
Rect boundsInScreen = boundsInParent;
int[] locationOnScreen = mTempArray;
getLocationOnScreen(locationOnScreen);
boundsInScreen.offset(locationOnScreen[0], locationOnScreen[1]);
boundsInScreen.scale(applicationScale);
info.setBoundsInScreen(boundsInScreen);
if (mAccessibilityFocusedView != View.NO_ID) {
info.addAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS);
}
if (mAccessibilityFocusedView == View.NO_ID) {
info.addAction(AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS);
}
if (NumberPicker.this.isEnabled()) {
if (getWrapSelectorWheel() || getValue() < getMaxValue()) {
info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
}
if (getWrapSelectorWheel() || getValue() > getMinValue()) {
info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD);
}
}
return info;
}