本文整理匯總了Java中android.graphics.Rect.set方法的典型用法代碼示例。如果您正苦於以下問題:Java Rect.set方法的具體用法?Java Rect.set怎麽用?Java Rect.set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.graphics.Rect
的用法示例。
在下文中一共展示了Rect.set方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getItemOffsets
import android.graphics.Rect; //導入方法依賴的package包/類
@Override
public void getItemOffsets(Rect outRect, View view,
RecyclerView parent, RecyclerView.State state) {
// outRect.left = space;
// outRect.right = space;
// outRect.bottom = space;
outRect.set(0, 20, 20, 20);
// Add top margin only for the first item to avoid double space between items
// if (parent.getChildLayoutPosition(view) == 0) {
// outRect.top = space;
// } else {
// outRect.top = 0;
// }
}
示例2: addShadowAndDescription
import android.graphics.Rect; //導入方法依賴的package包/類
/**
* Draw a shadow around the given bitmap.
* Also draw a description view on top of it
*
* @param artwork in
* @param descriptionView in
* @param srcCrop in
* @param shrinkFactor in
* @param shadowPaddingRect out
* @return
*/
public Bitmap addShadowAndDescription( Bitmap artwork, View descriptionView, Rect srcCrop, float shrinkFactor, Rect shadowPaddingRect) {
Rect spr = new Rect(0,0,0,0);
Bitmap destBitmap = addShadow(artwork, srcCrop, shrinkFactor, spr);
// Draw the description over the cover
if (descriptionView!=null) {
addDescription(destBitmap, descriptionView, spr);
}
if (shadowPaddingRect!=null) {
shadowPaddingRect.set(spr);
}
return destBitmap;
}
示例3: updateIconBounds
import android.graphics.Rect; //導入方法依賴的package包/類
private void updateIconBounds() {
if (null != mIconDrawable) {
Rect bounds = new Rect(mCircleDrawable.getBounds());
bounds.set(bounds.left + mIconInsetLeft, bounds.top + mIconInsetTop, bounds.right - mIconInsetRight, bounds.bottom - mIconInsetBottom);
mIconDrawable.setBounds(bounds);
}
}
示例4: getItemOffsets
import android.graphics.Rect; //導入方法依賴的package包/類
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
super.getItemOffsets(outRect, view, parent, state);
int position = ((RecyclerView.LayoutParams) view.getLayoutParams()).getViewLayoutPosition();
if (position > -1) {
if (position == 0) {
outRect.set(0, dp2px(view.getContext(), 18), 0, 0);
}
}
}
示例5: visibleFileRect
import android.graphics.Rect; //導入方法依賴的package包/類
/**
* Find the area of the source file that is currently visible on screen, taking into account the
* current scale, translation, orientation and clipped region. This is a convenience method; see
* {@link #viewToFileRect(Rect, Rect)}.
* @param fRect rectangle instance to which the result will be written. Re-use for efficiency.
*/
public void visibleFileRect(Rect fRect) {
if (vTranslate == null || !readySent) {
return;
}
fRect.set(0, 0, getWidth(), getHeight());
viewToFileRect(fRect, fRect);
}
示例6: getPadding
import android.graphics.Rect; //導入方法依賴的package包/類
@Override
public boolean getPadding(Rect padding) {
int vOffset = (int) Math.ceil(calculateVerticalPadding(mRawMaxShadowSize, mCornerRadius,
mAddPaddingForCorners));
// int hOffset = (int) Math.ceil(calculateHorizontalPadding(mRawMaxShadowSize, mCornerRadius,
// mAddPaddingForCorners));
// padding.set(hOffset, vOffset, hOffset, vOffset);
padding.set(0, vOffset, 0, 0);
return true;
}
示例7: getItemOffsets
import android.graphics.Rect; //導入方法依賴的package包/類
@Override
public void getItemOffsets(Rect outRect, int itemPosition, RecyclerView parent) {
if (mOrientation == VERTICAL_LIST) {
outRect.set(0, 0, 0, mDivider.getIntrinsicHeight());
} else {
outRect.set(0, 0, mDivider.getIntrinsicWidth(), 0);
}
}
示例8: getItemOffsets
import android.graphics.Rect; //導入方法依賴的package包/類
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
super.getItemOffsets(outRect, view, parent, state);
if (getOrientation(parent) == VERTICAL_LIST) {
outRect.set(0, 0, 0, mDivider.getIntrinsicHeight());
} else {
outRect.set(0, 0, mDivider.getIntrinsicWidth(), 0);
}
}
示例9: getIconRect
import android.graphics.Rect; //導入方法依賴的package包/類
protected Rect getIconRect(int viewWidth, int viewHeight, int drawableWidth, int drawableHeight) {
DragLayer dragLayer = mLauncher.getDragLayer();
// Find the rect to animate to (the view is center aligned)
Rect to = new Rect();
dragLayer.getViewRectRelativeToSelf(this, to);
final int width = drawableWidth;
final int height = drawableHeight;
final int left;
final int right;
if (Utilities.isRtl(getResources())) {
right = to.right - getPaddingRight();
left = right - width;
} else {
left = to.left + getPaddingLeft();
right = left + width;
}
final int top = to.top + (getMeasuredHeight() - height) / 2;
final int bottom = top + height;
to.set(left, top, right, bottom);
// Center the destination rect about the trash icon
final int xOffset = (int) -(viewWidth - width) / 2;
final int yOffset = (int) -(viewHeight - height) / 2;
to.offset(xOffset, yOffset);
return to;
}
示例10: getItemOffsets
import android.graphics.Rect; //導入方法依賴的package包/類
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
if (mOrientation == VERTICAL_LIST) {
outRect.set(0, 0, 0, mDivider.getIntrinsicHeight());
} else {
outRect.set(0, 0, mDivider.getIntrinsicWidth(), 0);
}
}
示例11: getContentRect
import android.graphics.Rect; //導入方法依賴的package包/類
private Rect getContentRect() {
Rect rect = new Rect();
if (!TextUtils.isEmpty(mContentText)) {
mTextPaint.getTextBounds(mContentText, 0, mContentText.length(), rect);
} else {
rect.set(0, 0, mContentBitmap.getWidth(), mContentBitmap.getHeight());
}
return rect;
}
示例12: getClippingRect
import android.graphics.Rect; //導入方法依賴的package包/類
@Override
public void getClippingRect(Rect outClippingRect) {
outClippingRect.set(Assertions.assertNotNull(mClippingRect));
}
示例13: getItemOffsets
import android.graphics.Rect; //導入方法依賴的package包/類
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
super.getItemOffsets(outRect, view, parent, state);
outRect.set(0, 0, 0, mDividerHeight);
}
示例14: getItemOffsets
import android.graphics.Rect; //導入方法依賴的package包/類
/**
* 預留分割線的空間,
* 主要是為了在每個Item的某一位置預留出分割線的空間 ,
* 從而讓Decoration繪製在預留的空間內,
* 注意這裏隻是預留了空間還沒有繪製內容的
*/
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
/**
* outRect.set(left, top, right, bottom);
* 在Item的四周設定距離
* 所以當Orientation為垂直時,我們隻需要在每個Item的下方預留出分割線的高度就可以了
* 同理當Orientation為水平時,我們隻需要在每個Item的右方預留出分割線的寬度就可以了
* 但通常我們使用分割線的style都是統一的,這樣我們在attrs中隻需要定義一個即可,即共同使用Height
*/
super.getItemOffsets(outRect, view, parent, state);
/**item位置*/
int position = parent.getChildAdapterPosition(view);
/**item總數*/
int count = parent.getAdapter().getItemCount();
/**列表方向*/
if (isVertical) {
/**豎向列表*/
if (position == 0) {
if (isMarginTopShow) {
/**第一個view,可以在頂部加一個margin值*/
outRect.set(0, mDividerHeight, 0, mDividerHeight);
} else {
if (isMiddleShow) {
outRect.set(0, 0, 0, mDividerHeight);
}
}
} else if (position >= count - 1) {
if (isMarginBottomshow) {
/**最後一個view,可以在底部加一個margin值*/
outRect.set(0, 0, 0, mDividerHeight);
}
} else {
if (isMiddleShow) {
/**畫橫線,就是往下偏移一個分割線的高度*/
outRect.set(0, 0, 0, mDividerHeight);
}
}
} else {
/**橫向列表*/
if (position == 0) {
if (isMarginTopShow) {
/**第一個view,可以在頂部加一個margin值*/
outRect.set(mDividerHeight, 0, mDividerHeight, 0);
} else {
if (isMiddleShow) {
outRect.set(0, 0, mDividerHeight, 0);
}
}
} else if (position >= count - 1) {
if (isMarginBottomshow) {
/**最後一個view,可以在底部加一個margin值*/
outRect.set(0, 0, mDividerHeight, 0);
}
} else {
if (isMiddleShow) {
/**畫豎線,就是往右偏移一個分割線的寬度*/
outRect.set(0, 0, mDividerHeight, 0);
}
}
}
}
示例15: getItemOffsets
import android.graphics.Rect; //導入方法依賴的package包/類
@Override public void getItemOffsets(Rect outRect, int position, int positionType) {
if (positionType == POSITION_LAST_ITEM) {
return;
}
outRect.set(0, 0, 0, mDivider.getIntrinsicHeight() * 4);
}