當前位置: 首頁>>代碼示例>>Java>>正文


Java Rect.centerX方法代碼示例

本文整理匯總了Java中android.graphics.Rect.centerX方法的典型用法代碼示例。如果您正苦於以下問題:Java Rect.centerX方法的具體用法?Java Rect.centerX怎麽用?Java Rect.centerX使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.graphics.Rect的用法示例。


在下文中一共展示了Rect.centerX方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: handleAccessibleDrop

import android.graphics.Rect; //導入方法依賴的package包/類
/**
 * @param clickedTarget the actual view that was clicked
 * @param dropLocation relative to {@param clickedTarget}. If provided, its center is used
 * as the actual drop location otherwise the views center is used.
 */
public void handleAccessibleDrop(View clickedTarget, Rect dropLocation,
        String confirmation) {
    if (!isInAccessibleDrag()) return;

    int[] loc = new int[2];
    if (dropLocation == null) {
        loc[0] = clickedTarget.getWidth() / 2;
        loc[1] = clickedTarget.getHeight() / 2;
    } else {
        loc[0] = dropLocation.centerX();
        loc[1] = dropLocation.centerY();
    }

    mLauncher.getDragLayer().getDescendantCoordRelativeToSelf(clickedTarget, loc);
    mLauncher.getDragController().completeAccessibleDrag(loc);

    if (!TextUtils.isEmpty(confirmation)) {
        announceConfirmation(confirmation);
    }
}
 
開發者ID:TeamBrainStorm,項目名稱:SimpleUILauncher,代碼行數:26,代碼來源:LauncherAccessibilityDelegate.java

示例2: offsetIfNeeded

import android.graphics.Rect; //導入方法依賴的package包/類
private void offsetIfNeeded(CoordinatorLayout parent, FloatingActionButton fab) {
    Rect padding = fab.mShadowPadding;
    if (padding != null && padding.centerX() > 0 && padding.centerY() > 0) {
        LayoutParams lp = (LayoutParams) fab.getLayoutParams();
        int offsetTB = 0;
        int offsetLR = 0;
        if (fab.getRight() >= parent.getWidth() - lp.rightMargin) {
            offsetLR = padding.right;
        } else if (fab.getLeft() <= lp.leftMargin) {
            offsetLR = -padding.left;
        }
        if (fab.getBottom() >= parent.getBottom() - lp.bottomMargin) {
            offsetTB = padding.bottom;
        } else if (fab.getTop() <= lp.topMargin) {
            offsetTB = -padding.top;
        }
        fab.offsetTopAndBottom(offsetTB);
        fab.offsetLeftAndRight(offsetLR);
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:21,代碼來源:FloatingActionButton.java

示例3: calculateCircleOval

import android.graphics.Rect; //導入方法依賴的package包/類
/**
 * Calculates rectangle(square) that will constraint chart circle.
 */
private void calculateCircleOval() {
    Rect contentRect = computator.getContentRectMinusAllMargins();
    final float circleRadius = Math.min(contentRect.width() / 2f, contentRect.height() / 2f);
    final float centerX = contentRect.centerX();
    final float centerY = contentRect.centerY();
    final float left = centerX - circleRadius + touchAdditional;
    final float top = centerY - circleRadius + touchAdditional;
    final float right = centerX + circleRadius - touchAdditional;
    final float bottom = centerY + circleRadius - touchAdditional;
    originCircleOval.set(left, top, right, bottom);
    final float inest = 0.5f * originCircleOval.width() * (1.0f - circleFillRatio);
    originCircleOval.inset(inest, inest);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:PieChartRenderer.java

示例4: getDirectionVectorForDrop

import android.graphics.Rect; //導入方法依賴的package包/類
private void getDirectionVectorForDrop(int dragViewCenterX, int dragViewCenterY, int spanX,
        int spanY, View dragView, int[] resultDirection) {
    int[] targetDestination = new int[2];

    findNearestArea(dragViewCenterX, dragViewCenterY, spanX, spanY, targetDestination);
    Rect dragRect = new Rect();
    regionToRect(targetDestination[0], targetDestination[1], spanX, spanY, dragRect);
    dragRect.offset(dragViewCenterX - dragRect.centerX(), dragViewCenterY - dragRect.centerY());

    Rect dropRegionRect = new Rect();
    getViewsIntersectingRegion(targetDestination[0], targetDestination[1], spanX, spanY,
            dragView, dropRegionRect, mIntersectingViews);

    int dropRegionSpanX = dropRegionRect.width();
    int dropRegionSpanY = dropRegionRect.height();

    regionToRect(dropRegionRect.left, dropRegionRect.top, dropRegionRect.width(),
            dropRegionRect.height(), dropRegionRect);

    int deltaX = (dropRegionRect.centerX() - dragViewCenterX) / spanX;
    int deltaY = (dropRegionRect.centerY() - dragViewCenterY) / spanY;

    if (dropRegionSpanX == mCountX || spanX == mCountX) {
        deltaX = 0;
    }
    if (dropRegionSpanY == mCountY || spanY == mCountY) {
        deltaY = 0;
    }

    if (deltaX == 0 && deltaY == 0) {
        // No idea what to do, give a random direction.
        resultDirection[0] = 1;
        resultDirection[1] = 0;
    } else {
        computeDirectionVector(deltaX, deltaY, resultDirection);
    }
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:38,代碼來源:CellLayout.java

示例5: scaleRectAboutCenter

import android.graphics.Rect; //導入方法依賴的package包/類
static void scaleRectAboutCenter(Rect r, float scale) {
    if (scale != 1.0f) {
        int cx = r.centerX();
        int cy = r.centerY();
        r.offset(-cx, -cy);

        r.left = (int) (r.left * scale + 0.5f);
        r.top = (int) (r.top * scale + 0.5f);
        r.right = (int) (r.right * scale + 0.5f);
        r.bottom = (int) (r.bottom * scale + 0.5f);

        r.offset(cx, cy);
    }
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:15,代碼來源:Utilities.java

示例6: getDrawRect

import android.graphics.Rect; //導入方法依賴的package包/類
public Rect getDrawRect() {
    Rect original = getBounds();
    int cX = original.centerX(), cY = original.centerY();
    rect.left = cX - (fullSize ? bigImgSize : drawImgSize) / 2;
    rect.right = cX + (fullSize ? bigImgSize : drawImgSize) / 2;
    rect.top = cY - (fullSize ? bigImgSize : drawImgSize) / 2;
    rect.bottom = cY + (fullSize ? bigImgSize : drawImgSize) / 2;
    return rect;
}
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:10,代碼來源:Emoji.java

示例7: findClosestColumn

import android.graphics.Rect; //導入方法依賴的package包/類
/**
 * Returns the column (0 indexed) closest to the previouslyFocusedRect or center if null.
 * The 0 index is related to the first day of the week.
 */
private int findClosestColumn(@Nullable Rect previouslyFocusedRect) {
    if (previouslyFocusedRect == null) {
        return DAYS_IN_WEEK / 2;
    } else {
        int mPaddingLeft = ViewCompat.getPaddingStart(this); // TODO is this good?
        int centerX = previouslyFocusedRect.centerX() - mPaddingLeft;
        final int columnFromLeft =
                mathConstrain(centerX / mCellWidth, 0, DAYS_IN_WEEK - 1);
        return isLayoutRtl() ? DAYS_IN_WEEK - columnFromLeft - 1 : columnFromLeft;
    }
}
 
開發者ID:Gericop,項目名稱:DateTimePicker,代碼行數:16,代碼來源:SimpleMonthView.java

示例8: PopupLayer

import android.graphics.Rect; //導入方法依賴的package包/類
public PopupLayer(Activity context, int radius) {
    super(context);
    mRadius = radius;
    mContext = context;
    Display display = context.getWindow().getWindowManager().getDefaultDisplay();
    mRectWindowRange = new Rect();
    btTempRect = new Rect();
    display.getRectSize(mRectWindowRange);
    mWindowCenterPoint = new Point(mRectWindowRange.centerX(), mRectWindowRange.centerY());
    mShadowView = new View(context);
    mShadowView.setBackgroundColor(Color.parseColor("#66000000"));
    mShadowView.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    addView(mShadowView);
}
 
開發者ID:panshen,項目名稱:PopupCircleMenu,代碼行數:15,代碼來源:PopupLayer.java

示例9: onBoundsChange

import android.graphics.Rect; //導入方法依賴的package包/類
@Override
protected void onBoundsChange(Rect bounds) {
    super.onBoundsChange(bounds);
    bounds = clipSquare(bounds);
    int radius = (int) (bounds.width() * Math.PI / 3f / getChildCount());
    int left = bounds.centerX() - radius;
    int right = bounds.centerX() + radius;
    for (int i = 0; i < getChildCount(); i++) {
        Dot dot = getChildAt(i);
        dot.setDrawBounds(left, bounds.top, right, bounds.top + radius * 2);
    }
}
 
開發者ID:liuwei1993,項目名稱:AndroidAnimationTools,代碼行數:13,代碼來源:RotatingDots.java

示例10: offsetIfNeeded

import android.graphics.Rect; //導入方法依賴的package包/類
/**
 * Pre-Lollipop we use padding so that the shadow has enough space to be drawn. This method
     * offsets our layout position so that we're positioned correctly if we're on one of
     * our parent's edges.
 */
private void offsetIfNeeded(CoordinatorLayout parent, FloatingActionButton fab) {
  final Rect padding = fab.mShadowPadding;

  if (padding != null && padding.centerX() > 0 && padding.centerY() > 0) {
    final CoordinatorLayout.LayoutParams lp =
        (CoordinatorLayout.LayoutParams) fab.getLayoutParams();

    int offsetTB = 0, offsetLR = 0;

    if (fab.getRight() >= parent.getWidth() - lp.rightMargin) {
      // If we're on the right edge, shift it the right
      offsetLR = padding.right;
    } else if (fab.getLeft() <= lp.leftMargin) {
      // If we're on the left edge, shift it the left
      offsetLR = -padding.left;
    }
    if (fab.getBottom() >= parent.getHeight() - lp.bottomMargin) {
      // If we're on the bottom edge, shift it down
      offsetTB = padding.bottom;
    } else if (fab.getTop() <= lp.topMargin) {
      // If we're on the top edge, shift it up
      offsetTB = -padding.top;
    }

    if (offsetTB != 0) {
      ViewCompat.offsetTopAndBottom(fab, offsetTB);
    }
    if (offsetLR != 0) {
      ViewCompat.offsetLeftAndRight(fab, offsetLR);
    }
  }
}
 
開發者ID:commonsguy,項目名稱:cwac-crossport,代碼行數:38,代碼來源:FloatingActionButton.java

示例11: draw

import android.graphics.Rect; //導入方法依賴的package包/類
@Override
public void draw(@NonNull Canvas canvas) {
    Rect bounds = getBounds();
    mBackground.draw(canvas);
    if (mText != null)
        canvas.drawText(mText, bounds.centerX(), bounds.centerY() - (mPaint.descent() + mPaint.ascent()) / 2, mPaint);
    if (mContentDrawable != null) {
        int cw = mContentDrawable.getIntrinsicWidth();
        int ch = mContentDrawable.getIntrinsicHeight();
        int cx = bounds.centerX() - cw / 2;
        int cy = bounds.centerY() - ch / 2;
        mContentDrawable.setBounds(cx, cy, cx + cw, cy + ch);
        mContentDrawable.draw(canvas);
    }
}
 
開發者ID:MCMrARM,項目名稱:revolution-irc,代碼行數:16,代碼來源:SimpleChipDrawable.java

示例12: IntroductoryOverlay

import android.graphics.Rect; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public IntroductoryOverlay(Builder builder, AttributeSet attrs, int defStyleAttr) {
    super(builder.mContext, attrs, defStyleAttr);
    mIsSingleTime = builder.mSingleTime;
    LayoutInflater inflater = LayoutInflater.from(getContext());
    inflater.inflate(R.layout.ccl_intro_overlay, this);
    mButton = (Button) findViewById(R.id.button);
    mTitleText = (TextView) findViewById(R.id.textTitle);
    mSubtitleText = (TextView) findViewById(R.id.textSubtitle);
    TypedArray typedArray = getContext().getTheme()
            .obtainStyledAttributes(attrs, R.styleable.CCLIntroOverlay,
                    R.attr.CCLIntroOverlayStyle, R.style.CCLIntroOverlay);
    if (builder.mOverlayColor != 0) {
        mOverlayColorId = builder.mOverlayColor;
    } else {
        mOverlayColorId = typedArray
                .getColor(R.styleable.CCLIntroOverlay_ccl_IntroBackgroundColor,
                        Color.argb(0, 0, 0, 0));
    }
    mFocusRadius = builder.mRadius;
    mListener = builder.mListener;
    if (mFocusRadius == 0) {
        mFocusRadius = typedArray
                .getDimension(R.styleable.CCLIntroOverlay_ccl_IntroFocusRadius, 0);
    }
    View view = builder.mView;
    Rect rect = new Rect();
    view.getGlobalVisibleRect(rect);
    mCenterX = rect.centerX();
    mCenterY = rect.centerY();
    setFitsSystemWindows(true);
    setupHolePaint();
    setText(builder.mTitleText, builder.mSubtitleText);

    setButton(builder.mButtonText, typedArray);
    typedArray.recycle();
}
 
開發者ID:SebastianRask,項目名稱:Pocket-Plays-for-Twitch,代碼行數:38,代碼來源:IntroductoryOverlay.java

示例13: calculateCircleOval

import android.graphics.Rect; //導入方法依賴的package包/類
private void calculateCircleOval() {
    Rect contentRect = this.computator.getContentRectMinusAllMargins();
    float circleRadius = Math.min(((float) contentRect.width()) / 2.0f, ((float) contentRect.height()) / 2.0f);
    float centerX = (float) contentRect.centerX();
    float centerY = (float) contentRect.centerY();
    this.originCircleOval.set((centerX - circleRadius) + ((float) this.touchAdditional), (centerY - circleRadius) + ((float) this.touchAdditional), (centerX + circleRadius) - ((float) this.touchAdditional), (centerY + circleRadius) - ((float) this.touchAdditional));
    float inest = (0.5f * this.originCircleOval.width()) * (1.0f - this.circleFillRatio);
    this.originCircleOval.inset(inest, inest);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:10,代碼來源:PieChartRenderer.java

示例14: centerX

import android.graphics.Rect; //導入方法依賴的package包/類
public static float centerX (Rect bounds, float withOf){
    float xStart;

    xStart=bounds.centerX()- (withOf/2f);

    return xStart;
}
 
開發者ID:gmontoya2483,項目名稱:GoUbiquitous,代碼行數:8,代碼來源:Utils.java

示例15: updateTextPosition

import android.graphics.Rect; //導入方法依賴的package包/類
/**
 * Update (x,y) positions of text.
 * @param textBounds Rect bounds based on text value.
 * @param width View width.
 */
private void updateTextPosition(Rect textBounds, int width) {
    textY = (int) ((lineY - linePaint.getStrokeWidth() / 2) - textMetrics.descent);
    textX = width / 2 - textBounds.centerX();
}
 
開發者ID:ppetarr,項目名稱:Android-LabelView,代碼行數:10,代碼來源:LabelView.java


注:本文中的android.graphics.Rect.centerX方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。