private Rect getRect(View view) {
Rect rect = new Rect();
rect.top = view.getTop();
rect.left = view.getLeft();
rect.right = view.getRight();
rect.bottom = view.getBottom();
ViewParent viewParent = view.getParent();
if (viewParent != null) {
if (viewParent instanceof ViewGroup) {
Rect prect = getRect((ViewGroup) viewParent);
rect.top += prect.top;
rect.left += prect.left;
rect.right += prect.left;
rect.bottom += prect.top;
}
}
return rect;
}
java类android.graphics.Rect的实例源码
PendIntentCompat.java 文件源码
项目:TPlayer
阅读 29
收藏 0
点赞 0
评论 0
SwipeBackLayout.java 文件源码
项目:OSchina_resources_android
阅读 30
收藏 0
点赞 0
评论 0
private void drawShadow(Canvas canvas, View child) {
final Rect childRect = mTmpRect;
child.getHitRect(childRect);
if ((mEdgeFlag & EDGE_LEFT) != 0) {
mShadowLeft.setBounds(childRect.left - mShadowLeft.getIntrinsicWidth(), childRect.top,
childRect.left, childRect.bottom);
mShadowLeft.setAlpha((int) (mScrimOpacity * FULL_ALPHA));
mShadowLeft.draw(canvas);
}
if ((mEdgeFlag & EDGE_RIGHT) != 0) {
mShadowRight.setBounds(childRect.right, childRect.top,
childRect.right + mShadowRight.getIntrinsicWidth(), childRect.bottom);
mShadowRight.setAlpha((int) (mScrimOpacity * FULL_ALPHA));
mShadowRight.draw(canvas);
}
if ((mEdgeFlag & EDGE_BOTTOM) != 0) {
mShadowBottom.setBounds(childRect.left, childRect.bottom, childRect.right,
childRect.bottom + mShadowBottom.getIntrinsicHeight());
mShadowBottom.setAlpha((int) (mScrimOpacity * FULL_ALPHA));
mShadowBottom.draw(canvas);
}
}
StickyHeaderDecoration.java 文件源码
项目:PeSanKita-android
阅读 23
收藏 0
点赞 0
评论 0
/**
* {@inheritDoc}
*/
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent,
RecyclerView.State state)
{
int position = parent.getChildAdapterPosition(view);
int headerHeight = 0;
if (position != RecyclerView.NO_POSITION && hasHeader(parent, adapter, position)) {
View header = getHeader(parent, adapter, position).itemView;
headerHeight = getHeaderHeightForLayout(header);
}
outRect.set(0, headerHeight, 0, 0);
}
NumberPicker.java 文件源码
项目:DateTimePicker
阅读 33
收藏 0
点赞 0
评论 0
private void scaleRect(Rect rect, float scale) {
if (scale != 1.0f) {
rect.left = (int) (rect.left * scale + 0.5f);
rect.top = (int) (rect.top * scale + 0.5f);
rect.right = (int) (rect.right * scale + 0.5f);
rect.bottom = (int) (rect.bottom * scale + 0.5f);
}
}
RExItemDecoration.java 文件源码
项目:RLibrary
阅读 32
收藏 0
点赞 0
评论 0
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
final RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();//布局管理器
final RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) view.getLayoutParams();
final int viewLayoutPosition = layoutParams.getViewLayoutPosition();//布局时当前View的位置
final int viewAdapterPosition = layoutParams.getViewAdapterPosition();
getItemOffsets(outRect, layoutManager, viewAdapterPosition, getEdge(viewAdapterPosition, layoutManager));
}
CustomViewAbove.java 文件源码
项目:ChatExchange-old
阅读 30
收藏 0
点赞 0
评论 0
private boolean isInIgnoredView(MotionEvent ev)
{
Rect rect = new Rect();
for (View v : mIgnoredViews)
{
v.getHitRect(rect);
if (rect.contains((int) ev.getX(), (int) ev.getY()))
{
return true;
}
}
return false;
}
ShareUtil.java 文件源码
项目:Huochexing12306
阅读 35
收藏 0
点赞 0
评论 0
/**
* 保存截图到sd卡 并返回截图路径
* @param activity
* @return
*/
public String getScreenShut(Activity activity){
View view = activity.getWindow().getDecorView();
view.setDrawingCacheEnabled(true);
view.buildDrawingCache();
Bitmap b1 = view.getDrawingCache();
// 获取状态栏高度
Rect frame = new Rect();
activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);
int statusBarHeight = frame.top;
// 获取屏幕长和高
int width = activity.getWindowManager().getDefaultDisplay().getWidth();
int height = activity.getWindowManager().getDefaultDisplay()
.getHeight();
// 去掉标题栏
Bitmap b = Bitmap.createBitmap(b1, 0, statusBarHeight, width, height
- statusBarHeight);
view.destroyDrawingCache();
//保存到sd卡
String sdCardRoot = Environment.getExternalStorageDirectory().getAbsolutePath();
String fileName = "shareIMG"+new Date().getTime()+".png";
String path = sdCardRoot+"/HuoCheXing/shareImage/"+fileName;
if(saveBitmapToSDCard(b,path)){
return path;
}
return null;
}
DragPreviewProvider.java 文件源码
项目:SimpleUILauncher
阅读 29
收藏 0
点赞 0
评论 0
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;
}
TouchDelegateViewGroup.java 文件源码
项目:AndroidDigIn
阅读 26
收藏 0
点赞 0
评论 0
public void setDelegateAreaColor(@ColorInt int color, Rect rect) {
paint = new Paint();
paint.setStyle(Paint.Style.FILL);
paint.setColor(color);
this.rect = rect;
invalidate();
}
ClickShadowView.java 文件源码
项目:LaunchEnr
阅读 20
收藏 0
点赞 0
评论 0
/**
* Aligns the shadow with {@param view}
* @param viewParent immediate parent of {@param view}. It must be a sibling of this view.
*/
public void alignWithIconView(BubbleTextView view, ViewGroup viewParent, View clipAgainstView) {
float leftShift = view.getLeft() + viewParent.getLeft() - getLeft();
float topShift = view.getTop() + viewParent.getTop() - getTop();
int iconWidth = view.getRight() - view.getLeft();
int iconHeight = view.getBottom() - view.getTop();
int iconHSpace = iconWidth - view.getCompoundPaddingRight() - view.getCompoundPaddingLeft();
float drawableWidth = view.getIcon().getBounds().width();
if (clipAgainstView != null) {
// Set the bounds to clip against
int[] coords = new int[] {0, 0};
Utilities.getDescendantCoordRelativeToAncestor(clipAgainstView, (View) getParent(),
coords, false);
int clipLeft = (int) Math.max(0, coords[0] - leftShift - mShadowPadding);
int clipTop = (int) Math.max(0, coords[1] - topShift - mShadowPadding) ;
setClipBounds(new Rect(clipLeft, clipTop, clipLeft + iconWidth, clipTop + iconHeight));
} else {
// Reset the clip bounds
setClipBounds(null);
}
setTranslationX(leftShift
+ viewParent.getTranslationX()
+ view.getCompoundPaddingLeft() * view.getScaleX()
+ (iconHSpace - drawableWidth) * view.getScaleX() / 2 /* drawable gap */
+ iconWidth * (1 - view.getScaleX()) / 2 /* gap due to scale */
- mShadowPadding /* extra shadow size */
);
setTranslationY(topShift
+ viewParent.getTranslationY()
+ view.getPaddingTop() * view.getScaleY() /* drawable gap */
+ view.getHeight() * (1 - view.getScaleY()) / 2 /* gap due to scale */
- mShadowPadding /* extra shadow size */
);
}