java类android.graphics.Rect的实例源码

CenteredImageSpan.java 文件源码 项目:ceji_android 阅读 33 收藏 0 点赞 0 评论 0
@Override
public int getSize(Paint paint, CharSequence text,
                   int start, int end,
                   Paint.FontMetricsInt fm) {
    Drawable d = getCachedDrawable();
    Rect rect = d.getBounds();

    if (fm != null) {
        // Centers the text with the ImageSpan
        if ((rect.bottom - (fm.descent - fm.ascent)) >= 0) {
            // Stores the initial descent and computes the margin available
            initialDescent = fm.descent;
            extraSpace = rect.bottom - (fm.descent - fm.ascent);
        }

        fm.descent = extraSpace / 2 + initialDescent;
        fm.bottom = fm.descent;

        fm.ascent = -rect.bottom + fm.descent;
        fm.top = fm.ascent;
    }

    return rect.right;
}
SearchSuggestionRecyclerView.java 文件源码 项目:tenor-android-demo-search 阅读 34 收藏 0 点赞 0 评论 0
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {

    if (!AbstractWeakReferenceUtils.isAlive(mWeakRef)) {
        return;
    }

    outRect.left = mSpaceBetweenItems / 2;
    outRect.top = 0;
    outRect.right = mSpaceBetweenItems / 2;
    outRect.bottom = 0;

    final int position = ((RecyclerView.LayoutParams) view.getLayoutParams()).getViewAdapterPosition();
    final int total = parent.getAdapter().getItemCount();
    if (position == 0) {
        outRect.left = mSpaceOnBothEnds;
    } else if (position == total - 1) {
        outRect.right = mSpaceOnBothEnds;
    }
}
ScreenShot.java 文件源码 项目:weex-3d-map 阅读 35 收藏 0 点赞 0 评论 0
public static  int getStatusBarHeight(Activity activity) {
    int result = 0;
    Rect rect = new Rect();
    Window window = activity.getWindow();
    if (window != null) {
        window.getDecorView().getWindowVisibleDisplayFrame(rect);
        View v = window.findViewById(Window.ID_ANDROID_CONTENT);

        android.view.Display display = ((android.view.WindowManager) activity.getSystemService(activity.WINDOW_SERVICE)).getDefaultDisplay();

        //return result title bar height
        int result1 = display.getHeight() - v.getBottom() + rect.top;
        int result2  = display.getHeight() - v.getBottom();
        int result3 = v.getTop() - rect.top;
        int result4 = display.getHeight() - v.getHeight();

        Log.e("StatusBarHeight==", "result1== " + result1 +" result2 = " + result2 + "result3=" + result3 + "result4=" +result4  ) ;
    }
    return result;

}
ProjectManagerActivity.java 文件源码 项目:javaide 阅读 38 收藏 0 点赞 0 评论 0
public void onGlobalLayout() {
    int i = 0;
    int navHeight = this.activity.getResources().getIdentifier("navigation_bar_height", "dimen", "android");
    navHeight = navHeight > 0 ? this.activity.getResources().getDimensionPixelSize(navHeight) : 0;
    int statusBarHeight = this.activity.getResources().getIdentifier("status_bar_height", "dimen", "android");
    if (statusBarHeight > 0) {
        i = this.activity.getResources().getDimensionPixelSize(statusBarHeight);
    }
    Rect rect = new Rect();
    activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(rect);
    if (activity.mDrawerLayout.getRootView().getHeight() - ((navHeight + i) + rect.height()) <= 0) {
        activity.onHideKeyboard();
    } else {
        activity.onShowKeyboard();
    }
}
SearchView.java 文件源码 项目:CSipSimple 阅读 35 收藏 0 点赞 0 评论 0
private void adjustDropDownSizeAndPosition() {
    if (mDropDownAnchor.getWidth() > 1) {
        Resources res = getContext().getResources();
        int anchorPadding = mSearchPlate.getPaddingLeft();
        Rect dropDownPadding = new Rect();
        int iconOffset = mIconifiedByDefault
                ? res.getDimensionPixelSize(R.dimen.abs__dropdownitem_icon_width)
                + res.getDimensionPixelSize(R.dimen.abs__dropdownitem_text_padding_left)
                : 0;
        mQueryTextView.getDropDownBackground().getPadding(dropDownPadding);
        mQueryTextView.setDropDownHorizontalOffset(-(dropDownPadding.left + iconOffset)
                + anchorPadding);
        mQueryTextView.setDropDownWidth(mDropDownAnchor.getWidth() + dropDownPadding.left
                + dropDownPadding.right + iconOffset - (anchorPadding));
    }
}
ForwardingDrawableTest.java 文件源码 项目:GitHub 阅读 44 收藏 0 点赞 0 评论 0
@Test
public void testCopyProperties() {
  Rect rect = new Rect(10, 20, 30, 40);
  int config = 11;
  int level = 100;
  boolean visible = true;
  int[] stateSet = new int[]{1, 2};

  mDrawable.setBounds(rect);
  mDrawable.setChangingConfigurations(config);
  mDrawable.setLevel(level);
  mDrawable.setVisible(visible, false);
  mDrawable.setState(stateSet);

  Drawable newDrawable = mock(Drawable.class);
  mDrawable.setCurrent(newDrawable);

  verify(newDrawable).setBounds(rect);
  verify(newDrawable).setChangingConfigurations(config);
  verify(newDrawable).setLevel(level);
  verify(newDrawable).setVisible(visible, false);
  verify(newDrawable).setState(stateSet);
}
HighlightView.java 文件源码 项目:MyAnimeViewer 阅读 50 收藏 0 点赞 0 评论 0
public void setup(Matrix m, Rect imageRect, RectF cropRect, boolean circle,
                  boolean maintainAspectRatio) {

    if (circle) {
        maintainAspectRatio = true;
    }
    mMatrix = new Matrix(m);

    mCropRect = cropRect;
    mImageRect = new RectF(imageRect);
    mMaintainAspectRatio = maintainAspectRatio;
    mCircle = circle;

    mInitialAspectRatio = mCropRect.width() / mCropRect.height();
    mDrawRect = computeLayout();

    mFocusPaint.setARGB(125, 50, 50, 50);
    mNoFocusPaint.setARGB(125, 50, 50, 50);
    mOutlinePaint.setStrokeWidth(3F);
    mOutlinePaint.setStyle(Paint.Style.STROKE);
    mOutlinePaint.setAntiAlias(true);

    mMode = ModifyMode.None;
    init();
}
ClearEditText.java 文件源码 项目:UnversityFinance 阅读 33 收藏 0 点赞 0 评论 0
@Override
protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
    super.onFocusChanged(focused, direction, previouslyFocusedRect);
    isFocused = focused;
    if (focused && getText().length() > 0) {
        if (!isVisible) {
            isVisible = true;
            startVisibleAnimator();
        }
    } else {
        if (isVisible) {
            isVisible = false;
            startGoneAnimator();
        }
    }
}
CoolWaitLoadingRenderer.java 文件源码 项目:JueDiQiuSheng 阅读 39 收藏 0 点赞 0 评论 0
@Override
protected void draw(Canvas canvas, Rect bounds) {
    int saveCount = canvas.save();
    RectF arcBounds = mCurrentBounds;
    arcBounds.set(bounds);

    mPaint.setColor(mBottomColor);
    canvas.drawPath(mCurrentBottomWaitPath, mPaint);

    mPaint.setColor(mMiddleColor);
    canvas.drawPath(mCurrentMiddleWaitPath, mPaint);

    mPaint.setColor(mTopColor);
    canvas.drawPath(mCurrentTopWaitPath, mPaint);

    canvas.restoreToCount(saveCount);
}
SocialResHelper.java 文件源码 项目:boohee_v5.6 阅读 35 收藏 0 点赞 0 评论 0
private static Bitmap getRoundedCornerBitmap(Bitmap bitmap) {
    Bitmap createBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config
            .ARGB_8888);
    Canvas canvas = new Canvas(createBitmap);
    Paint paint = new Paint();
    Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
    RectF rectF = new RectF(rect);
    paint.setAntiAlias(true);
    canvas.drawARGB(0, 0, 0, 0);
    paint.setColor(-12434878);
    if (RESUTIL_V2_DUBUG) {
        canvas.drawRoundRect(rectF, (float) (bitmap.getWidth() / 2), (float) (bitmap
                .getHeight() / 2), paint);
    } else {
        canvas.drawRoundRect(rectF, (float) (bitmap.getWidth() / 6), (float) (bitmap
                .getHeight() / 6), paint);
    }
    paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
    canvas.drawBitmap(bitmap, rect, rect, paint);
    bitmap.recycle();
    return createBitmap;
}
WheelView.java 文件源码 项目:GitHub 阅读 39 收藏 0 点赞 0 评论 0
private void measuredOutContentStart(String content) {
    Rect rect = new Rect();
    paintOuterText.getTextBounds(content, 0, content.length(), rect);
    switch (mGravity) {
        case Gravity.CENTER:
            if (isOptions||label == null|| label.equals("")||!isCenterLabel) {
                drawOutContentStart = (int) ((measuredWidth - rect.width()) * 0.5);
            } else {//只显示中间label时,时间选择器内容偏左一点,留出空间绘制单位标签
                drawOutContentStart = (int) ((measuredWidth - rect.width()) * 0.25);
            }
            break;
        case Gravity.LEFT:
            drawOutContentStart = 0;
            break;
        case Gravity.RIGHT:
            drawOutContentStart = measuredWidth - rect.width()-(int)centerContentOffset;
            break;
    }
}
ProviderPickerActivity.java 文件源码 项目:OpenYOLO-Android 阅读 30 收藏 0 点赞 0 评论 0
@Override
public boolean dispatchTouchEvent(MotionEvent event) {

    // finishWithUserCanceled() if the user tapped outside the picker
    if (MotionEvent.ACTION_DOWN == event.getAction()) {
        Rect visibilityRect = new Rect();
        mPickerContainer.getGlobalVisibleRect(visibilityRect);
        boolean tappedOutsidePicker =
                !visibilityRect.contains((int) event.getRawX(), (int) event.getRawY());
        if (tappedOutsidePicker) {
            finishWithUserCanceled();
        }
    }

    return super.dispatchTouchEvent(event);
}
ViewfinderView.java 文件源码 项目:letv 阅读 35 收藏 0 点赞 0 评论 0
private void drawScanningLine(Canvas canvas, Rect frame) {
    if (this.isFirst) {
        this.isFirst = false;
        this.slideTop = 0;
        this.slideBottom = frame.bottom - frame.top;
    }
    this.slideTop += 6;
    if (this.slideTop >= this.slideBottom - MIDDLE_LINE_WIDTH) {
        this.slideTop = 0;
    }
    Rect lineRect = new Rect();
    lineRect.left = frame.left + MIDDLE_LINE_PADDING;
    lineRect.right = frame.right - MIDDLE_LINE_PADDING;
    lineRect.top = frame.top + this.slideTop;
    lineRect.bottom = (frame.top + this.slideTop) + MIDDLE_LINE_WIDTH;
    canvas.drawBitmap(((BitmapDrawable) getResources().getDrawable(R.drawable.sweep_laser)).getBitmap(), null, lineRect, this.paint);
}
PendIntentCompat.java 文件源码 项目:VirtualHook 阅读 36 收藏 0 点赞 0 评论 0
private void setIntentByViewGroup(RemoteViews remoteViews, ViewGroup viewGroup, List<RectInfo> list) {
        int count = viewGroup.getChildCount();
        Rect p = new Rect();
        viewGroup.getHitRect(p);
        for (int i = 0; i < count; i++) {
            View v = viewGroup.getChildAt(i);
            if (v instanceof ViewGroup) {
                // linearlayout
                setIntentByViewGroup(remoteViews, (ViewGroup) v, list);
            } else if (v instanceof TextView || v instanceof ImageView) {
                // textview
                Rect rect = getRect(v);
                RectInfo next = findIntent(rect, list);
                if (next != null) {
//                  VLog.d(TAG, next.rect+":setPendIntent:"+i);
//                    remoteViews.setImageViewBitmap(v.getId(), next.testBg);
                    remoteViews.setOnClickPendingIntent(v.getId(), next.mPendingIntent);
                }
            }
        }
    }
MaterialProgressDrawable.java 文件源码 项目:SmartRefreshLayout 阅读 36 收藏 0 点赞 0 评论 0
/**
 * Draw the progress spinner
 */
public void draw(Canvas c, Rect bounds) {
    final RectF arcBounds = mTempBounds;
    arcBounds.set(bounds);
    arcBounds.inset(mStrokeInset, mStrokeInset);

    final float startAngle = (mStartTrim + mRotation) * 360;
    final float endAngle = (mEndTrim + mRotation) * 360;
    float sweepAngle = endAngle - startAngle;

    if (sweepAngle != 0) {
        mPaint.setColor(mCurrentColor);
        c.drawArc(arcBounds, startAngle, sweepAngle, false, mPaint);
    }

    drawTriangle(c, startAngle, sweepAngle, bounds);

    if (mAlpha < 255) {
        mCirclePaint.setColor(mBackgroundColor);
        mCirclePaint.setAlpha(255 - mAlpha);
        c.drawCircle(bounds.exactCenterX(), bounds.exactCenterY(), bounds.width() / 2,
                mCirclePaint);
    }
}
CameraManager.java 文件源码 项目:MeiLa_GNN 阅读 34 收藏 0 点赞 0 评论 0
/**
     * Like {@link #getFramingRect} but coordinates are in terms of the preview frame,
     * not UI / screen.
     */
    public Rect getFramingRectInPreview() {
        if (framingRectInPreview == null) {
            Rect rect = new Rect(getFramingRect());
            Point cameraResolution = configManager.getCameraResolution();
            Point screenResolution = configManager.getScreenResolution();
            //modify here
//      rect.left = rect.left * cameraResolution.x / screenResolution.x;
//      rect.right = rect.right * cameraResolution.x / screenResolution.x;
//      rect.top = rect.top * cameraResolution.y / screenResolution.y;
//      rect.bottom = rect.bottom * cameraResolution.y / screenResolution.y;
            rect.left = rect.left * cameraResolution.y / screenResolution.x;
            rect.right = rect.right * cameraResolution.y / screenResolution.x;
            rect.top = rect.top * cameraResolution.x / screenResolution.y;
            rect.bottom = rect.bottom * cameraResolution.x / screenResolution.y;
            framingRectInPreview = rect;
        }
        return framingRectInPreview;
    }
BadgeDrawable.java 文件源码 项目:XERUNG 阅读 30 收藏 0 点赞 0 评论 0
@Override
public void draw(Canvas canvas) {
    if (!mWillDraw) {
        return;
    }

    Rect bounds = getBounds();
    float width = 50;
    float height = 50;

    // Position the badge in the top-right quadrant of the icon.
    float radius = ((Math.min(width, height) / 2) - 1) / 2;
    float centerX = width - radius - 1;
    float centerY = radius + 1;

    // Draw badge circle.
    canvas.drawCircle(centerX, centerY, radius, mBadgePaint);

    // Draw badge count text inside the circle.
    mTextPaint.getTextBounds(mCount, 0, mCount.length(), mTxtRect);
    float textHeight = mTxtRect.bottom - mTxtRect.top;
    float textY = centerY + (textHeight / 2f);
    canvas.drawText(mCount, centerX, textY, mTextPaint);
}
TMReminderTagsView.java 文件源码 项目:Virtualview-Android 阅读 87 收藏 0 点赞 0 评论 0
public TMReminderTagsView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    if (mDensity == -1) {
        initWith(context);
    }
    textPaint = new TextPaint();
    textPaint.setAntiAlias(true);
    textPaint.setColor(Color.rgb(255, 59, 68));
    textPaint.setTextSize(dp2px(10));

    bgPaint = new Paint();
    bgPaint.setColor(Color.rgb(250, 211, 213));

    tagsGap = dp2px(7);

    hPadding = dp2px(3);

    tagRect = new Rect();

    textFontMetrics = textPaint.getFontMetrics();
}
HorizontalDividerItemDecoration.java 文件源码 项目:RX_Demo 阅读 46 收藏 0 点赞 0 评论 0
@Override
protected Rect getDividerBound(int position, RecyclerView parent, View child) {
    Rect bounds = new Rect(0, 0, 0, 0);
    int transitionX = (int) ViewCompat.getTranslationX(child);
    int transitionY = (int) ViewCompat.getTranslationY(child);
    RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
    bounds.left = parent.getPaddingLeft() +
            mMarginProvider.dividerLeftMargin(position, parent) + transitionX;
    bounds.right = parent.getWidth() - parent.getPaddingRight() -
            mMarginProvider.dividerRightMargin(position, parent) + transitionX;

    int dividerSize = getDividerSize(position, parent);
    if (mDividerType == DividerType.DRAWABLE) {
        bounds.top = child.getBottom() + params.topMargin + transitionY;
        bounds.bottom = bounds.top + dividerSize;
    } else {
        bounds.top = child.getBottom() + params.topMargin + dividerSize / 2 + transitionY;
        bounds.bottom = bounds.top;
    }

    return bounds;
}
ImageUtils.java 文件源码 项目:HeadlineNews 阅读 36 收藏 0 点赞 0 评论 0
/**
 * 转为圆形图片
 *
 * @param src     源图片
 * @param recycle 是否回收
 * @return 圆形图片
 */
public static Bitmap toRound(final Bitmap src, final boolean recycle) {
    if (isEmptyBitmap(src)) return null;
    int width = src.getWidth();
    int height = src.getHeight();
    int radius = Math.min(width, height) >> 1;
    Bitmap ret = Bitmap.createBitmap(width, height, src.getConfig());
    Paint paint = new Paint();
    Canvas canvas = new Canvas(ret);
    Rect rect = new Rect(0, 0, width, height);
    paint.setAntiAlias(true);
    canvas.drawARGB(0, 0, 0, 0);
    canvas.drawCircle(width >> 1, height >> 1, radius, paint);
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(src, rect, rect, paint);
    if (recycle && !src.isRecycled()) src.recycle();
    return ret;
}
ViewfinderView.java 文件源码 项目:Zxing 阅读 37 收藏 0 点赞 0 评论 0
public ViewfinderView(Context context, AttributeSet attrs) {
    super(context, attrs);

    // Initialize these once for performance rather than calling them every
    // time in onDraw().
    paint = new Paint();
    Resources resources = getResources();
    maskColor = resources.getColor(R.color.viewfinder_mask);
    resultColor = resources.getColor(R.color.result_view);
    resultPointColor = resources.getColor(R.color.possible_result_points);
    possibleResultPoints = new HashSet<ResultPoint>(5);
    path = new Path();
    lineRect = new Rect();
    /**
     * 获取屏幕密度
     */
    density = context.getResources().getDisplayMetrics().density;
    ScreenRate = (int) (20 * density);
}
QMUIMaterialProgressDrawable.java 文件源码 项目:qmui 阅读 30 收藏 0 点赞 0 评论 0
/**
 * Draw the progress spinner
 */
public void draw(Canvas c, Rect bounds) {
    final RectF arcBounds = mTempBounds;
    arcBounds.set(bounds);
    arcBounds.inset(mStrokeInset, mStrokeInset);

    final float startAngle = (mStartTrim + mRotation) * 360;
    final float endAngle = (mEndTrim + mRotation) * 360;
    float sweepAngle = endAngle - startAngle;

    mPaint.setColor(mCurrentColor);
    c.drawArc(arcBounds, startAngle, sweepAngle, false, mPaint);

    drawTriangle(c, startAngle, sweepAngle, bounds);

    if (mAlpha < 255) {
        mCirclePaint.setColor(mBackgroundColor);
        mCirclePaint.setAlpha(255 - mAlpha);
        c.drawCircle(bounds.exactCenterX(), bounds.exactCenterY(), bounds.width() / 2,
                mCirclePaint);
    }
}
SwipeLayout.java 文件源码 项目:Views 阅读 37 收藏 0 点赞 0 评论 0
void layoutLayDown() {
    View surfaceView = getSurfaceView();
    Rect surfaceRect = mViewBoundCache.get(surfaceView);
    if (surfaceRect == null) surfaceRect = computeSurfaceLayoutArea(false);
    if (surfaceView != null) {
        surfaceView.layout(surfaceRect.left, surfaceRect.top, surfaceRect.right, surfaceRect.bottom);
        bringChildToFront(surfaceView);
    }
    View currentBottomView = getCurrentBottomView();
    Rect bottomViewRect = mViewBoundCache.get(currentBottomView);
    if (bottomViewRect == null)
        bottomViewRect = computeBottomLayoutAreaViaSurface(ShowMode.LayDown, surfaceRect);
    if (currentBottomView != null) {
        currentBottomView.layout(bottomViewRect.left, bottomViewRect.top, bottomViewRect.right, bottomViewRect.bottom);
    }
}
TabLayoutManager.java 文件源码 项目:InfiniteTabsView 阅读 30 收藏 0 点赞 0 评论 0
/**
 * Fill right of the center view
 *
 * @param recycler
 * @param startPosition start position to fill right
 * @param startOffset   layout start offset
 * @param rightEdge
 */
private void fillRight(RecyclerView.Recycler recycler, int startPosition, int startOffset, int rightEdge) {
    View scrap;
    int topOffset;
    int scrapWidth, scrapHeight;
    Rect scrapRect = new Rect();
    int height = getVerticalSpace();
    for (int i = startPosition; i < getItemCount() && startOffset < rightEdge; i++) {
        scrap = recycler.getViewForPosition(i);
        addView(scrap);
        measureChildWithMargins(scrap, 0, 0);
        scrapWidth = getDecoratedMeasuredWidth(scrap);
        scrapHeight = getDecoratedMeasuredHeight(scrap);
        topOffset = (int) (getPaddingTop() + (height - scrapHeight) / 2.0f);
        scrapRect.set(startOffset, topOffset, startOffset + scrapWidth, topOffset + scrapHeight);
        layoutDecorated(scrap, scrapRect.left, scrapRect.top, scrapRect.right, scrapRect.bottom);
        startOffset = scrapRect.right;
        mLastVisiblePos = i;
        if (getState().mItemsFrames.get(i) == null) {
            getState().mItemsFrames.put(i, scrapRect);
        } else {
            getState().mItemsFrames.get(i).set(scrapRect);
        }
    }
}
ChargeAmountDividerDecoration.java 文件源码 项目:GitHub 阅读 30 收藏 0 点赞 0 评论 0
@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;
//            }
        }
bilibili.java 文件源码 项目:stynico 阅读 31 收藏 0 点赞 0 评论 0
private Bitmap getCircleBitmap(final int radius)
{
       final Bitmap output = Bitmap.createBitmap(originBitmap.getWidth(), originBitmap.getHeight(), Bitmap.Config.ARGB_8888);
       final Canvas canvas = new Canvas(output);
       final Paint paint = new Paint();
       final Rect rect = new Rect((int)(x - radius), (int)(y - radius), (int)(x + radius), (int)(y + radius));

       paint.setAntiAlias(true);
       canvas.drawARGB(0, 0, 0, 0);
       canvas.drawCircle(x, y, radius, paint);

       paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
       canvas.drawBitmap(originBitmap, rect, rect, paint);

       return output;
   }
Blockies.java 文件源码 项目:Lunary-Ethereum-Wallet 阅读 30 收藏 0 点赞 0 评论 0
public static Bitmap getCroppedBitmap(Bitmap bitmap) {
    Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
            bitmap.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(output);

    final int color = 0xff424242;
    final Paint paint = new Paint();
    final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());

    paint.setAntiAlias(true);
    canvas.drawARGB(0, 0, 0, 0);
    paint.setColor(color);
    canvas.drawCircle(bitmap.getWidth() / 2, bitmap.getHeight() / 2,
            bitmap.getWidth() / 2, paint);
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(bitmap, rect, rect, paint);
    return output;
}
NestedScrollView.java 文件源码 项目:letv 阅读 40 收藏 0 点赞 0 评论 0
public NestedScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    this.mTempRect = new Rect();
    this.mIsLayoutDirty = true;
    this.mIsLaidOut = false;
    this.mChildToScrollTo = null;
    this.mIsBeingDragged = false;
    this.mSmoothScrollingEnabled = true;
    this.mActivePointerId = -1;
    this.mScrollOffset = new int[2];
    this.mScrollConsumed = new int[2];
    initScrollView();
    TypedArray a = context.obtainStyledAttributes(attrs, SCROLLVIEW_STYLEABLE, defStyleAttr, 0);
    setFillViewport(a.getBoolean(0, false));
    a.recycle();
    this.mParentHelper = new NestedScrollingParentHelper(this);
    this.mChildHelper = new NestedScrollingChildHelper(this);
    setNestedScrollingEnabled(true);
    ViewCompat.setAccessibilityDelegate(this, ACCESSIBILITY_DELEGATE);
}
SunLineView.java 文件源码 项目:stynico 阅读 41 收藏 0 点赞 0 评论 0
private void init() {
    Log.i(Tag, "init");

    mLineWidth = changeDp(1);
    mLineHeight = changeDp(3);
    mFixLineHeight = changeDp(6);
    mSunRadius = changeDp(12);
    mLineColor = Color.RED;
    mLineLevel = 30;

    //线的配置
    mLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mLinePaint.setColor(mLineColor);
    mLinePaint.setStyle(Paint.Style.FILL_AND_STROKE);
    // 设置画笔宽度
    mLinePaint.setStrokeWidth(mLineWidth);
    mDrawFilter = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG
            | Paint.FILTER_BITMAP_FLAG);
    debugRect = new Rect();
    mouthRect = new RectF();
}
RecyclerView.java 文件源码 项目:PlusGram 阅读 34 收藏 0 点赞 0 评论 0
Rect getItemDecorInsetsForChild(View child) {
    final LayoutParams lp = (LayoutParams) child.getLayoutParams();
    if (!lp.mInsetsDirty) {
        return lp.mDecorInsets;
    }

    final Rect insets = lp.mDecorInsets;
    insets.set(0, 0, 0, 0);
    final int decorCount = mItemDecorations.size();
    for (int i = 0; i < decorCount; i++) {
        mTempRect.set(0, 0, 0, 0);
        mItemDecorations.get(i).getItemOffsets(mTempRect, child, this, mState);
        insets.left += mTempRect.left;
        insets.top += mTempRect.top;
        insets.right += mTempRect.right;
        insets.bottom += mTempRect.bottom;
    }
    lp.mInsetsDirty = false;
    return insets;
}


问题


面经


文章

微信
公众号

扫码关注公众号