本文整理匯總了Java中android.graphics.Rect.inset方法的典型用法代碼示例。如果您正苦於以下問題:Java Rect.inset方法的具體用法?Java Rect.inset怎麽用?Java Rect.inset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.graphics.Rect
的用法示例。
在下文中一共展示了Rect.inset方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: moveBy
import android.graphics.Rect; //導入方法依賴的package包/類
void moveBy(float dx, float dy) {
Rect invalRect = new Rect(mDrawRect);
mCropRect.offset(dx, dy);
// Put the cropping rectangle inside image rectangle.
mCropRect.offset(
Math.max(0, mImageRect.left - mCropRect.left),
Math.max(0, mImageRect.top - mCropRect.top));
mCropRect.offset(
Math.min(0, mImageRect.right - mCropRect.right),
Math.min(0, mImageRect.bottom - mCropRect.bottom));
mDrawRect = computeLayout();
invalRect.union(mDrawRect);
invalRect.inset(-10, -10);
mContext.invalidate(invalRect);
}
示例2: draw
import android.graphics.Rect; //導入方法依賴的package包/類
@Override
public void draw(Canvas canvas) {
int height = getBounds().height();
int width = getBounds().width();
// allow drawing out of bounds vertically
Rect clipBounds = canvas.getClipBounds();
clipBounds.inset(-12, -12);
canvas.clipRect(clipBounds, Region.Op.REPLACE);
RectF rect = new RectF(0.0f, 0.0f, width, height);
// background
canvas.drawRoundRect(rect, mRadius, mRadius, mPaintBg);
// border
canvas.drawRoundRect(rect, mRadius, mRadius, mPaintBorder);
}
示例3: drawShadow
import android.graphics.Rect; //導入方法依賴的package包/類
private void drawShadow(Canvas canvas) {
if (shadowDrawable != null) {
Rect newRect = canvas.getClipBounds();
Log.d(TAG,"ShadowParentView has blur! " + newRect);
newRect.inset(-shadowPadding, -shadowPadding);
canvas.clipRect (newRect, Region.Op.REPLACE);
shadowDrawable.draw(canvas);
}
}
示例4: startDragging
import android.graphics.Rect; //導入方法依賴的package包/類
private boolean startDragging(MotionEvent ev, boolean ignoreTrackIfInScrollContainer) {
final Rect bounds = mTempRect;
mThumb.copyBounds(bounds);
//Grow the current thumb rect for a bigger touch area
bounds.inset(-mAddedTouchBounds, -mAddedTouchBounds);
mIsDragging = (bounds.contains((int) ev.getX(), (int) ev.getY()));
if (!mIsDragging && mAllowTrackClick && !ignoreTrackIfInScrollContainer) {
//If the user clicked outside the thumb, we compute the current position
//and force an immediate drag to it.
mIsDragging = true;
mDragOffset = (bounds.width() / 2) - mAddedTouchBounds;
updateDragging(ev);
//As the thumb may have moved, getBitmapForVisualizer the bounds again
mThumb.copyBounds(bounds);
bounds.inset(-mAddedTouchBounds, -mAddedTouchBounds);
}
if (mIsDragging) {
setPressed(true);
attemptClaimDrag();
setHotspot(ev.getX(), ev.getY());
mDragOffset = (int) (ev.getX() - bounds.left - mAddedTouchBounds);
if (mPublicChangeListener != null) {
mPublicChangeListener.onStartTrackingTouch(this);
}
}
return mIsDragging;
}
示例5: updateThumbPos
import android.graphics.Rect; //導入方法依賴的package包/類
private void updateThumbPos(int posX) {
int thumbWidth = mThumb.getIntrinsicWidth();
int halfThumb = thumbWidth / 2;
int start;
if (isRtl()) {
start = getWidth() - getPaddingRight() - mAddedTouchBounds;
posX = start - posX - thumbWidth;
} else {
start = getPaddingLeft() + mAddedTouchBounds;
posX = start + posX;
}
mThumb.copyBounds(mInvalidateRect);
mThumb.setBounds(posX, mInvalidateRect.top, posX + thumbWidth, mInvalidateRect.bottom);
if (isRtl()) {
mScrubber.getBounds().right = start - halfThumb;
mScrubber.getBounds().left = posX + halfThumb;
} else {
mScrubber.getBounds().left = start + halfThumb;
mScrubber.getBounds().right = posX + halfThumb;
}
final Rect finalBounds = mTempRect;
mThumb.copyBounds(finalBounds);
if (!isInEditMode()) {
mIndicator.move(finalBounds.centerX());
}
mInvalidateRect.inset(-mAddedTouchBounds, -mAddedTouchBounds);
finalBounds.inset(-mAddedTouchBounds, -mAddedTouchBounds);
mInvalidateRect.union(finalBounds);
SeekBarCompat.setHotspotBounds(mRipple, finalBounds.left, finalBounds.top, finalBounds.right, finalBounds.bottom);
invalidate(mInvalidateRect);
}
示例6: startDragging
import android.graphics.Rect; //導入方法依賴的package包/類
private boolean startDragging(MotionEvent ev, boolean ignoreTrackIfInScrollContainer) {
final Rect bounds = mTempRect;
mThumb.copyBounds(bounds);
//Grow the current thumb rect for a bigger touch area
bounds.inset(-mAddedTouchBounds, -mAddedTouchBounds);
mIsDragging = (bounds.contains((int) ev.getX(), (int) ev.getY()));
if (!mIsDragging && mAllowTrackClick && !ignoreTrackIfInScrollContainer) {
//If the user clicked outside the thumb, we compute the current position
//and force an immediate drag to it.
mIsDragging = true;
mDragOffset = (bounds.width() / 2) - mAddedTouchBounds;
updateDragging(ev);
//As the thumb may have moved, get the bounds again
mThumb.copyBounds(bounds);
bounds.inset(-mAddedTouchBounds, -mAddedTouchBounds);
}
if (mIsDragging) {
setPressed(true);
attemptClaimDrag();
setHotspot(ev.getX(), ev.getY());
mDragOffset = (int) (ev.getX() - bounds.left - mAddedTouchBounds);
if (mPublicChangeListener != null) {
mPublicChangeListener.onStartTrackingTouch(this);
}
}
return mIsDragging;
}
示例7: updateThumbPos
import android.graphics.Rect; //導入方法依賴的package包/類
private void updateThumbPos(int posX) {
int thumbWidth = mThumb.getIntrinsicWidth();
int halfThumb = thumbWidth / 2;
int start;
if (isRtl()) {
start = getWidth() - getPaddingRight() - mAddedTouchBounds;
posX = start - posX - thumbWidth;
} else {
start = getPaddingLeft() + mAddedTouchBounds;
posX = start + posX;
}
mThumb.copyBounds(mInvalidateRect);
mThumb.setBounds(posX, mInvalidateRect.top, posX + thumbWidth, mInvalidateRect.bottom);
if (isRtl()) {
mScrubber.getBounds().right = start - halfThumb;
mScrubber.getBounds().left = posX + halfThumb;
} else {
mScrubber.getBounds().left = start + halfThumb;
mScrubber.getBounds().right = posX + halfThumb;
}
final Rect finalBounds = mTempRect;
mThumb.copyBounds(finalBounds);
if (!isInEditMode()) {
mIndicator.move(finalBounds.centerX());
}
mInvalidateRect.inset(-mAddedTouchBounds, -mAddedTouchBounds);
finalBounds.inset(-mAddedTouchBounds, -mAddedTouchBounds);
mInvalidateRect.union(finalBounds);
SeekBar.setHotspotBounds(mRipple, finalBounds.left, finalBounds.top, finalBounds.right, finalBounds.bottom);
invalidate(mInvalidateRect);
}
示例8: getDrawableBounds
import android.graphics.Rect; //導入方法依賴的package包/類
protected static Rect getDrawableBounds(Drawable d) {
Rect bounds = new Rect();
d.copyBounds(bounds);
if (bounds.width() == 0 || bounds.height() == 0) {
bounds.set(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
} else {
bounds.offsetTo(0, 0);
}
if (d instanceof PreloadIconDrawable) {
int inset = -((PreloadIconDrawable) d).getOutset();
bounds.inset(inset, inset);
}
return bounds;
}
示例9: renderNoPage
import android.graphics.Rect; //導入方法依賴的package包/類
private void renderNoPage(Bitmap bitmap, final RenderListener listener, Rect localVisRect, Rect globalVisRect)
{
// specify where to draw to and from
mDrawBitmap = bitmap;
mDrawSrcRect.set(globalVisRect);
mDrawDstRect.set(localVisRect);
// make a rect representing the entire page in screen coordinates
int[] locations = new int[2];
getLocationOnScreen(locations);
Rect pageRect = new Rect(locations[0], locations[1], locations[0] + getWidth(), locations[1] + getHeight());
// draw a yellow page with a red border containing the page number
Paint p = new Paint();
Canvas c = new Canvas(bitmap);
p.setColor(Color.RED);
p.setStyle(Paint.Style.FILL);
c.drawRect(pageRect, p);
Rect smaller = new Rect(pageRect);
int inset = (int) (40 * mScale);
smaller.inset(inset, inset);
p.setColor(Color.YELLOW);
p.setStyle(Paint.Style.FILL);
c.drawRect(smaller, p);
String s = "" + (mPageNum + 1);
p.setColor(Color.BLACK);
p.setTextSize(200.0f * mScale);
c.drawText(s, pageRect.left + (90 * mScale), pageRect.top + (290 * mScale), p);
invalidate();
listener.progress(0);
}
示例10: explode
import android.graphics.Rect; //導入方法依賴的package包/類
/**
* 爆炸
* @param view 爆炸view
* @param isJitterAnima 是否執行抖動動畫
* @param listener 動畫結束回調
*/
public void explode(final View view, boolean isJitterAnima, OnAnimationEndListener listener) {
Rect r = new Rect();
view.getGlobalVisibleRect(r); //view
int[] location = new int[2];
getLocationOnScreen(location);
r.offset(-location[0], -location[1]);
r.inset(-mExpandInset[0], -mExpandInset[1]);
int startDelay = 100;
if(isJitterAnima){
ValueAnimator animator = ValueAnimator.ofFloat(0f, 1f).setDuration(150);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
Random random = new Random();
@Override
public void onAnimationUpdate(ValueAnimator animation) {
view.setTranslationX((random.nextFloat() - 0.5f) * view.getWidth() * 0.05f);
view.setTranslationY((random.nextFloat() - 0.5f) * view.getHeight() * 0.05f);
}
});
animator.start();
view.animate().setDuration(150).setStartDelay(startDelay).scaleX(0f).scaleY(0f).alpha(0f).start();
}else{
view.setScaleX(0);
view.setScaleY(0);
view.setAlpha(0);
}
explode(BitmapUtils.createBitmapFromView(view), r, startDelay, ExplosionAnimator.DEFAULT_DURATION, listener);
}
示例11: onDraw
import android.graphics.Rect; //導入方法依賴的package包/類
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
mAction.getIcon().setState(getActionState());
float x = getCircleCenterX();
float y = getCircleCenterY();
mBackgroundPaint.setShadowLayer(getCurrentShadowRadius(), 0, getShadowOffsetY(), Color.parseColor("#50000000"));
mBackgroundPaint.setColor(mConfigHelper.getBackgroundColorStateList().getColorForState(getActionState(), Color.GRAY));
canvas.drawCircle(x, y, getInterpolatedRadius(), mBackgroundPaint);
Drawable icon = mAction.getIcon();
mTempPoint.x = (int) x;
mTempPoint.y = (int) y;
Rect bounds = getRectInsideCircle(mTempPoint, getInterpolatedRadius());
bounds.inset(mIconPadding, mIconPadding);
float aspect = icon.getIntrinsicWidth() / (float) (icon.getIntrinsicHeight());
int desiredWidth = (int) Math.min(bounds.width(), bounds.height() * aspect);
int desiredHeight = (int) Math.min(bounds.height(), bounds.width() / aspect);
bounds.inset((bounds.width() - desiredWidth) / 2, (bounds.height() - desiredHeight) / 2);
icon.setBounds(bounds);
mAction.getIcon().draw(canvas);
}
示例12: handleTouchEvent
import android.graphics.Rect; //導入方法依賴的package包/類
/**
* Handles the touch events to dismiss all apps when clicking outside the bounds of the
* recycler view.
*/
private boolean handleTouchEvent(MotionEvent ev) {
DeviceProfile grid = mLauncher.getDeviceProfile();
int x = (int) ev.getX();
int y = (int) ev.getY();
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN:
if (!mContentBounds.isEmpty()) {
// Outset the fixed bounds and check if the touch is outside all apps
Rect tmpRect = new Rect(mContentBounds);
tmpRect.inset(-grid.allAppsIconSizePx / 2, 0);
if (ev.getX() < tmpRect.left || ev.getX() > tmpRect.right) {
mBoundsCheckLastTouchDownPos.set(x, y);
return true;
}
} else {
// Check if the touch is outside all apps
if (ev.getX() < getPaddingLeft() ||
ev.getX() > (getWidth() - getPaddingRight())) {
mBoundsCheckLastTouchDownPos.set(x, y);
return true;
}
}
break;
case MotionEvent.ACTION_UP:
if (mBoundsCheckLastTouchDownPos.x > -1) {
ViewConfiguration viewConfig = ViewConfiguration.get(getContext());
float dx = ev.getX() - mBoundsCheckLastTouchDownPos.x;
float dy = ev.getY() - mBoundsCheckLastTouchDownPos.y;
float distance = (float) Math.hypot(dx, dy);
if (distance < viewConfig.getScaledTouchSlop()) {
// The background was clicked, so just go home
Launcher launcher = Launcher.getLauncher(getContext());
launcher.showWorkspace(true);
return true;
}
}
// Fall through
case MotionEvent.ACTION_CANCEL:
mBoundsCheckLastTouchDownPos.set(-1, -1);
break;
}
return false;
}
示例13: bang
import android.graphics.Rect; //導入方法依賴的package包/類
public void bang(final View view, float radius, OnBangListener listener) {
// set listener
if (listener != null) {
setOnBangListener(listener);
this.mBangListener.onAnimationStart();
}
Rect r = new Rect();
view.getGlobalVisibleRect(r);
int[] location = new int[2];
getLocationOnScreen(location);
r.offset(-location[0], -location[1]);
r.inset(-mExpandInset[0], -mExpandInset[1]);
centerX = r.left + r.width() / 2;
centerY = r.top + r.height() / 2;
if (radius != -1) {
initRadius(radius);
} else {
initRadius(Math.max(r.width(), r.height()));
}
view.setScaleX(0.1f);
view.setScaleY(0.1f);
ValueAnimator animator = ValueAnimator.ofFloat(0f, 1f).setDuration((long) (ANIMATE_DURATION * 0.5f));
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float animatedFraction = animation.getAnimatedFraction();
view.setScaleX(0.1f + animatedFraction * 0.9f);
view.setScaleY(0.1f + animatedFraction * 0.9f);
}
});
animator.setInterpolator(new OvershootInterpolator(2));
animator.setStartDelay((long) (ANIMATE_DURATION * P3));
animator.start();
bang();
}
示例14: innerStroke
import android.graphics.Rect; //導入方法依賴的package包/類
private Rect innerStroke(int strokeWidth, Rect rect) {
int offset = strokeWidth / 2;
Rect newRect = new Rect(rect);
newRect.inset(offset, offset);
return newRect;
}
示例15: outerStroke
import android.graphics.Rect; //導入方法依賴的package包/類
private Rect outerStroke(int strokeWidth, int left, int top, int right, int bottom) {
int offset = strokeWidth / 2;
Rect newRect = new Rect(left, top, right, bottom);
newRect.inset(-offset, -offset);
return newRect;
}