本文整理汇总了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);
}