Beispiel #1
0
 public override void draw(android.graphics.Canvas canvas)
 {
     if (mPicture != null)
     {
         android.graphics.Rect bounds = getBounds();
         canvas.save();
         canvas.clipRect(bounds);
         canvas.translate(bounds.left, bounds.top);
         canvas.drawPicture(mPicture);
         canvas.restore();
     }
 }
Beispiel #2
0
        protected internal override void onDraw(android.graphics.Canvas canvas)
        {
            base.onDraw(canvas);
            // Draw the switch
            int switchLeft   = mSwitchLeft;
            int switchTop    = mSwitchTop;
            int switchRight  = mSwitchRight;
            int switchBottom = mSwitchBottom;

            mTrackDrawable.setBounds(switchLeft, switchTop, switchRight, switchBottom);
            mTrackDrawable.draw(canvas);
            canvas.save();
            mTrackDrawable.getPadding(mTempRect);
            int switchInnerLeft   = switchLeft + mTempRect.left;
            int switchInnerTop    = switchTop + mTempRect.top;
            int switchInnerRight  = switchRight - mTempRect.right;
            int switchInnerBottom = switchBottom - mTempRect.bottom;

            canvas.clipRect(switchInnerLeft, switchTop, switchInnerRight, switchBottom);
            mThumbDrawable.getPadding(mTempRect);
            int thumbPos   = (int)(mThumbPosition + 0.5f);
            int thumbLeft  = switchInnerLeft - mTempRect.left + thumbPos;
            int thumbRight = switchInnerLeft + thumbPos + mThumbWidth + mTempRect.right;

            mThumbDrawable.setBounds(thumbLeft, switchTop, thumbRight, switchBottom);
            mThumbDrawable.draw(canvas);
            // mTextColors should not be null, but just in case
            if (mTextColors != null)
            {
                mTextPaint.setColor(mTextColors.getColorForState(getDrawableState(), mTextColors.
                                                                 getDefaultColor()));
            }
            mTextPaint.drawableState = getDrawableState();
            android.text.Layout switchText = getTargetCheckedState() ? mOnLayout : mOffLayout;
            canvas.translate((thumbLeft + thumbRight) / 2 - switchText.getWidth() / 2, (switchInnerTop
                                                                                        + switchInnerBottom) / 2 - switchText.getHeight() / 2);
            switchText.draw(canvas);
            canvas.restore();
        }
Beispiel #3
0
 protected internal override void onDraw(android.graphics.Canvas canvas)
 {
     base.onDraw(canvas);
     if (mDrawable == null)
     {
         return;
     }
     // couldn't resolve the URI
     if (mDrawableWidth == 0 || mDrawableHeight == 0)
     {
         return;
     }
     // nothing to draw (empty bounds)
     if (mDrawMatrix == null && mPaddingTop == 0 && mPaddingLeft == 0)
     {
         mDrawable.draw(canvas);
     }
     else
     {
         int saveCount = canvas.getSaveCount();
         canvas.save();
         if (mCropToPadding)
         {
             int scrollX = mScrollX;
             int scrollY = mScrollY;
             canvas.clipRect(scrollX + mPaddingLeft, scrollY + mPaddingTop, scrollX + mRight -
                             mLeft - mPaddingRight, scrollY + mBottom - mTop - mPaddingBottom);
         }
         canvas.translate(mPaddingLeft, mPaddingTop);
         if (mDrawMatrix != null)
         {
             canvas.concat(mDrawMatrix);
         }
         mDrawable.draw(canvas);
         canvas.restoreToCount(saveCount);
     }
 }
Beispiel #4
0
        public override void draw(android.graphics.Canvas canvas)
        {
            if (mClipState.mDrawable.getLevel() == 0)
            {
                return;
            }
            android.graphics.Rect r      = mTmpRect;
            android.graphics.Rect bounds = getBounds();
            int level = getLevel();
            int w     = bounds.width();
            int iw    = 0;

            //mClipState.mDrawable.getIntrinsicWidth();
            if ((mClipState.mOrientation & HORIZONTAL) != 0)
            {
                w -= (w - iw) * (10000 - level) / 10000;
            }
            int h  = bounds.height();
            int ih = 0;

            //mClipState.mDrawable.getIntrinsicHeight();
            if ((mClipState.mOrientation & VERTICAL) != 0)
            {
                h -= (h - ih) * (10000 - level) / 10000;
            }
            int layoutDirection = getResolvedLayoutDirectionSelf();

            android.view.Gravity.apply(mClipState.mGravity, w, h, bounds, r, layoutDirection);
            if (w > 0 && h > 0)
            {
                canvas.save();
                canvas.clipRect(r);
                mClipState.mDrawable.draw(canvas);
                canvas.restore();
            }
        }