android.graphics.Paint Java Examples

The following examples show how to use android.graphics.Paint. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SketchShapeBitmapDrawable.java    From sketch with Apache License 2.0 6 votes vote down vote up
public SketchShapeBitmapDrawable(@NonNull Context context, @NonNull BitmapDrawable bitmapDrawable, @Nullable ShapeSize shapeSize, @Nullable ImageShaper shaper) {
    Bitmap bitmap = bitmapDrawable.getBitmap();
    if (bitmap == null || bitmap.isRecycled()) {
        throw new IllegalArgumentException(bitmap == null ? "bitmap is null" : "bitmap recycled");
    }

    if (shapeSize == null && shaper == null) {
        throw new IllegalArgumentException("shapeSize is null and shapeImage is null");
    }

    this.bitmapDrawable = bitmapDrawable;
    this.paint = new Paint(DEFAULT_PAINT_FLAGS);
    this.srcRect = new Rect();
    this.resizeCalculator = Sketch.with(context).getConfiguration().getResizeCalculator();

    setShapeSize(shapeSize);
    setShaper(shaper);

    if (bitmapDrawable instanceof SketchRefDrawable) {
        this.refDrawable = (SketchRefDrawable) bitmapDrawable;
    }

    if (bitmapDrawable instanceof SketchDrawable) {
        this.sketchDrawable = (SketchDrawable) bitmapDrawable;
    }
}
 
Example #2
Source File: DrawerArrowDrawable.java    From browser with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param context
 *            used to get the configuration for the drawable from
 */
public DrawerArrowDrawable(Context context) {
	final TypedArray typedArray = context.getTheme().obtainStyledAttributes(null,
			R.styleable.DrawerArrowToggle, R.attr.drawerArrowStyle,
			R.style.Base_Widget_AppCompat_DrawerArrowToggle);
	mPaint.setAntiAlias(true);
	mPaint.setColor(typedArray.getColor(R.styleable.DrawerArrowToggle_color, 0));
	mSize = typedArray.getDimensionPixelSize(R.styleable.DrawerArrowToggle_drawableSize, 0);
	mBarSize =0;// typedArray.getDimension(R.styleable.DrawerArrowToggle_barSize, 0);
	mTopBottomArrowSize = //typedArray.getDimension(R.styleable.DrawerArrowToggle_topBottomBarArrowSize, 0);
	mBarThickness = typedArray.getDimension(R.styleable.DrawerArrowToggle_thickness, 0);
	mBarGap = typedArray.getDimension(R.styleable.DrawerArrowToggle_gapBetweenBars, 0);
	mSpin = typedArray.getBoolean(R.styleable.DrawerArrowToggle_spinBars, true);
	mMiddleArrowSize =0;// typedArray.getDimension(R.styleable.DrawerArrowToggle_middleBarArrowSize, 0);
	typedArray.recycle();
	mPaint.setStyle(Paint.Style.STROKE);
	mPaint.setStrokeJoin(Paint.Join.ROUND);
	mPaint.setStrokeCap(Paint.Cap.SQUARE);
	mPaint.setStrokeWidth(mBarThickness);
}
 
Example #3
Source File: TitlePageIndicator.java    From InfiniteViewPager with MIT License 6 votes vote down vote up
/**
 * Calculate views bounds and scroll them according to the current index
 *
 * @param paint
 * @return
 */
private ArrayList<Rect> calculateAllBounds(Paint paint) {
    ArrayList<Rect> list = new ArrayList<Rect>();
    //For each views (If no values then add a fake one)
    final int count = InfiniteViewPager.FakePositionHelper.getAdapterSize(mViewPager);
    final int width = getWidth();
    final int halfWidth = width / 2;
    for (int i = 0; i < count; i++) {
        Rect bounds = calcBounds(i, paint);
        int w = bounds.right - bounds.left;
        int h = bounds.bottom - bounds.top;
        bounds.left = (int)(halfWidth - (w / 2f) + ((i - mCurrentPage - mPageOffset) * width));
        bounds.right = bounds.left + w;
        bounds.top = 0;
        bounds.bottom = h;
        list.add(bounds);
    }

    return list;
}
 
Example #4
Source File: MetronomeView.java    From Metronome-Android with Apache License 2.0 6 votes vote down vote up
public MetronomeView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    paint = new Paint();
    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeWidth(2);
    paint.setAntiAlias(true);
    paint.setColor(Color.BLACK);

    accentPaint = new Paint();
    accentPaint.setStyle(Paint.Style.STROKE);
    accentPaint.setStrokeWidth(8);
    accentPaint.setAntiAlias(true);
    accentPaint.setColor(Color.BLACK);

    subscribe();
}
 
Example #5
Source File: SlidingPaneLayout.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
private void dimChildView(View v, float mag, int fadeColor) {
    final LayoutParams lp = (LayoutParams) v.getLayoutParams();

    if (mag > 0 && fadeColor != 0) {
        final int baseAlpha = (fadeColor & 0xff000000) >>> 24;
        int imag = (int) (baseAlpha * mag);
        int color = imag << 24 | (fadeColor & 0xffffff);
        if (lp.dimPaint == null) {
            lp.dimPaint = new Paint();
        }
        lp.dimPaint.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_OVER));
        if (ViewCompat.getLayerType(v) != ViewCompat.LAYER_TYPE_HARDWARE) {
            ViewCompat.setLayerType(v, ViewCompat.LAYER_TYPE_HARDWARE, lp.dimPaint);
        }
        invalidateChildRegion(v);
    } else if (ViewCompat.getLayerType(v) != ViewCompat.LAYER_TYPE_NONE) {
        if (lp.dimPaint != null) {
            lp.dimPaint.setColorFilter(null);
        }
        final DisableLayerRunnable dlr = new DisableLayerRunnable(v);
        mPostedRunnables.add(dlr);
        ViewCompat.postOnAnimation(this, dlr);
    }
}
 
Example #6
Source File: EmoticonSpan.java    From EmoticonGIFKeyboard with Apache License 2.0 6 votes vote down vote up
@Override
public int getSize(final Paint paint, final CharSequence text, final int start,
                   final int end, final Paint.FontMetricsInt fontMetrics) {
    if (fontMetrics != null) {
        final Paint.FontMetrics paintFontMetrics = paint.getFontMetrics();
        final float fontHeight = paintFontMetrics.descent - paintFontMetrics.ascent;
        final float centerY = paintFontMetrics.ascent + fontHeight / 2;

        fontMetrics.ascent = (int) (centerY - mEmoticonSize / 2);
        fontMetrics.top = fontMetrics.ascent;
        fontMetrics.bottom = (int) (centerY + mEmoticonSize / 2);
        fontMetrics.descent = fontMetrics.bottom;
    }

    return (int) mEmoticonSize;
}
 
Example #7
Source File: ChangeColorItem.java    From SlidingTabWithColorIcons with Apache License 2.0 6 votes vote down vote up
/**
 */
private void setupTargetBitmap(int alpha) {
    if (mBitmap == null) {
        mBitmap = textAsBitmap("-");
    }
    if (mIconBitmap == null) {
        mIconBitmap = textAsBitmap("-");
    }
    mBitmap = Bitmap.createBitmap(getMeasuredWidth(), getMeasuredHeight(), Config.ARGB_8888);
    Canvas mCanvas = new Canvas(mBitmap);
    Paint mPaint = new Paint();
    mPaint.setColor(mIconColor);
    mPaint.setAntiAlias(true);
    mPaint.setDither(true);
    mPaint.setAlpha(alpha);
    mCanvas.drawRect(mIconRect, mPaint);
    mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
    mPaint.setAlpha(255);
    mCanvas.drawBitmap(mIconBitmap, null, mIconRect, mPaint);

}
 
Example #8
Source File: MaterialCheckbox.java    From FilePicker with Apache License 2.0 6 votes vote down vote up
public void initView(Context context) {
    this.context = context;
    checked = false;
    tick = new Path();
    paint = new Paint();
    bounds = new RectF();
    OnClickListener onClickListener = new OnClickListener() {
        @Override
        public void onClick(View v) {
            setChecked(!checked);
            onCheckedChangeListener.onCheckedChanged(MaterialCheckbox.this, isChecked());
        }
    };

    setOnClickListener(onClickListener);
}
 
Example #9
Source File: RadialMenuView.java    From talkback with Apache License 2.0 6 votes vote down vote up
private static String getEllipsizedText(Paint paint, String title, float maxWidth) {
  final float textWidth = paint.measureText(title);
  if (textWidth <= maxWidth) {
    return title;
  }

  // Find the maximum length with an ellipsis.
  final float ellipsisWidth = paint.measureText(ELLIPSIS);
  final int length = paint.breakText(title, true, (maxWidth - ellipsisWidth), null);

  // Try to land on a word break.
  // TODO: Use breaking iterator for better i18n support.
  final int space = title.lastIndexOf(' ', length);
  if (space > 0) {
    return title.substring(0, space) + ELLIPSIS;
  }

  // Otherwise, cut off characters.
  return title.substring(0, length) + ELLIPSIS;
}
 
Example #10
Source File: WheelView.java    From WheelViewDemo with Apache License 2.0 6 votes vote down vote up
private void initConfig() {
    textPaint.setColor(textColor);
    textPaint.setTextSize(textSize);
    Paint.FontMetrics fontMetrics = textPaint.getFontMetrics();

    String testText = "菜单选项";
    Rect rect = new Rect();
    textPaint.getTextBounds(testText, 0, testText.length(), rect);
    itemHeight = rect.height() + itemVerticalSpace;
    textBaseLine = -itemHeight / 2.0f + (itemHeight - fontMetrics.bottom + fontMetrics.top) / 2 - fontMetrics.top;

    if (showCount < 5) {
        showCount = 5;
    }
    if (showCount % 2 == 0) {
        showCount++;
    }
    drawCount = showCount + 2;
    defaultRectArray = new Rect[drawCount];
    drawRectArray = new Rect[drawCount];
    for (int i = 0; i < drawCount; i++) {
        defaultRectArray[i] = new Rect();
        drawRectArray[i] = new Rect();
    }
}
 
Example #11
Source File: GraphData.java    From AndroidAPS with GNU Affero General Public License v3.0 6 votes vote down vote up
public void addNowLine(long now) {
    LineGraphSeries<DataPoint> seriesNow;
    DataPoint[] nowPoints = new DataPoint[]{
            new DataPoint(now, 0),
            new DataPoint(now, maxY)
    };

    seriesNow = new LineGraphSeries<>(nowPoints);
    seriesNow.setDrawDataPoints(false);
    // custom paint to make a dotted line
    Paint paint = new Paint();
    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeWidth(2);
    paint.setPathEffect(new DashPathEffect(new float[]{10, 20}, 0));
    paint.setColor(Color.WHITE);
    seriesNow.setCustomPaint(paint);

    addSeries(seriesNow);
}
 
Example #12
Source File: TextMeasureUtil.java    From FastTextView with Apache License 2.0 6 votes vote down vote up
/**
 * Do not support cross Span.
 *
 * @param text       text
 * @param parentSpan parentSpan
 * @param start      start index of parentSpan
 * @param end        end index of parentSpan
 * @param paint      TextPaint
 * @return recursive calculated width
 */
public int recursiveGetSizeWithReplacementSpan(CharSequence text, ReplacementSpan parentSpan, @IntRange(from = 0) int start, @IntRange(from = 0) int end, Paint paint) {
  if (text instanceof Spanned) {
    Spanned spannedText = (Spanned) text;
    List<ReplacementSpan> spans = getSortedReplacementSpans(spannedText, start, end);
    if (!spans.isEmpty()) {
      int lastIndexCursor = 0;
      int width = 0;
      for (ReplacementSpan span : spans) {
        if (span == parentSpan) {
          continue;
        }
        int spanStart = spannedText.getSpanStart(span);
        int spanEnd = spannedText.getSpanEnd(span);
        width += parentSpan.getSize(paint, text, lastIndexCursor, spanStart, null);
        width += span.getSize(paint, text, spanStart, spanEnd, null);
        lastIndexCursor = spanEnd;
      }
      if (lastIndexCursor < end) {
        width += parentSpan.getSize(paint, text, lastIndexCursor, end, null);
      }
      return width;
    }
  }
  return parentSpan.getSize(paint, text, start, end, null);
}
 
Example #13
Source File: PaperProgressBar.java    From PaperStyleWidgets with MIT License 6 votes vote down vote up
public PaperProgressBar(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    final TypedArray a = context.getTheme().obtainStyledAttributes(
            attrs, R.styleable.PaperProgressBar, defStyleAttr, 0);
    try {
        mProgressColor = a.getColor(R.styleable.PaperProgressBar_pw_progressColor, 0xFF0F9D58);
        // Secondary progress by default is same color, but half transparent
        mSecondaryProgressColor = a.getColor(R.styleable.PaperProgressBar_pw_secondaryProgressColor,
                0x7F000000 | (mProgressColor & 0xFFFFFF));
    } finally {
        a.recycle();
    }

    mColorPaint.setColor(mProgressColor);
    mColorPaint.setStyle(Paint.Style.FILL);
    mColorPaint.setAntiAlias(true);

    mIndeterminateProgress = 0;
    if (isIndeterminate()) {
        mIndeterminateHandler.sendEmptyMessage(0);
    }
}
 
Example #14
Source File: AnimatedImageSpan.java    From imsdk-android with MIT License 5 votes vote down vote up
@Override
public void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, Paint paint) {
    Drawable b = getDrawable();
    canvas.save();

    int transY = bottom - b.getBounds().bottom;
    if (mVerticalAlignment == ALIGN_BASELINE) {
        transY -= paint.getFontMetricsInt().descent;
    }

    canvas.translate(x, transY);
    b.draw(canvas);
    canvas.restore();

}
 
Example #15
Source File: HyperImageView.java    From YCCustomText with Apache License 2.0 5 votes vote down vote up
private void initData() {
    //画笔
    paint = new Paint();
    //设置颜色
    paint.setColor(borderColor);
    //设置画笔的宽度
    paint.setStrokeWidth(borderWidth);
    //设置画笔的风格-不能设成填充FILL否则看不到图片
    paint.setStyle(Paint.Style.STROKE);
}
 
Example #16
Source File: ViewHolder.java    From MVVM-JueJin with MIT License 5 votes vote down vote up
public ViewHolder setTypeface(Typeface typeface, int... viewIds) {
    for (int viewId : viewIds) {
        TextView view = getView(viewId);
        view.setTypeface(typeface);
        view.setPaintFlags(view.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
    }
    return this;
}
 
Example #17
Source File: DrawView.java    From privacy-friendly-pin-mnemonic with GNU General Public License v3.0 5 votes vote down vote up
/**
 *
 * @param startView button where arrow/line starts
 * @param endView button where arrow/line finishes
 * @param digitOne digit on first button
 * @param digitTwo digit on second button
 */
public DrawView(Context context, View startView, View endView, int digitOne, int digitTwo) {
    super(context);
    this.startView = startView;
    this.endView = endView;
    this.digitOne = digitOne;
    this.digitTwo = digitTwo;
    paint = new Paint();
    paint.setAntiAlias(true);
    paint.setAlpha(150);
}
 
Example #18
Source File: CircularSeekBar.java    From CircularSeekBar with Apache License 2.0 5 votes vote down vote up
@Override
protected void onRestoreInstanceState(Parcelable state) {
    Bundle savedState = (Bundle) state;

    Parcelable superState = savedState.getParcelable("PARENT");
    super.onRestoreInstanceState(superState);

    mMax = savedState.getFloat("MAX");
    mProgress = savedState.getFloat("PROGRESS");
    mCircleColor = savedState.getInt("mCircleColor");
    mCircleProgressColor = savedState.getInt("mCircleProgressColor");
    mPointerColor = savedState.getInt("mPointerColor");
    mPointerHaloColor = savedState.getInt("mPointerHaloColor");
    mPointerHaloColorOnTouch = savedState.getInt("mPointerHaloColorOnTouch");
    mPointerAlpha = savedState.getInt("mPointerAlpha");
    mPointerAlphaOnTouch = savedState.getInt("mPointerAlphaOnTouch");
    mPointerAngle = savedState.getFloat("mPointerAngle");
    mDisablePointer = savedState.getBoolean("mDisablePointer");
    mLockEnabled = savedState.getBoolean("mLockEnabled");
    mNegativeEnabled = savedState.getBoolean("mNegativeEnabled");
    mDisableProgressGlow = savedState.getBoolean("mDisableProgressGlow");
    mIsInNegativeHalf = savedState.getBoolean("mIsInNegativeHalf");
    mCircleStyle = Paint.Cap.values()[savedState.getInt("mCircleStyle")];
    mHideProgressWhenEmpty = savedState.getBoolean("mHideProgressWhenEmpty");

    initPaints();

    recalculateAll();
}
 
Example #19
Source File: Label.java    From clear-todolist with GNU General Public License v3.0 5 votes vote down vote up
private void init() {
    setLayerType(LAYER_TYPE_SOFTWARE, null);
    mPaint.setStyle(Paint.Style.FILL);
    mPaint.setColor(mColorNormal);

    mErase.setXfermode(PORTER_DUFF_CLEAR);

    if (!isInEditMode()) {
        mPaint.setShadowLayer(mShadowRadius, mShadowXOffset, mShadowYOffset, mShadowColor);
    }
}
 
Example #20
Source File: RippleView.java    From RippleEffect with MIT License 5 votes vote down vote up
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;
}
 
Example #21
Source File: SubmitButton.java    From SubmitButton with MIT License 5 votes vote down vote up
void init(AttributeSet attrs) {

        TypedArray typeArray = getContext().obtainStyledAttributes(attrs,
                R.styleable.SubmitButton);
        mButtonPaint = new Paint();
        mInitBtnColor = typeArray.getColor(R.styleable.SubmitButton_sub_btn_background,
                ContextCompat.getColor(getContext(), R.color.sub_btn_background));
        mButtonPaint.setColor(mInitBtnColor);
        mButtonPaint.setAntiAlias(true);
        mLinePaint = new Paint();
        mLineColor = typeArray.getColor(R.styleable.SubmitButton_sub_btn_line_color,
                ContextCompat.getColor(getContext(), R.color.sub_btn_line));
        mLinePaint.setColor(mLineColor);
        mLinePaint.setStyle(Paint.Style.STROKE);
        mLinePaint.setAntiAlias(true);
        mTickPaint = new Paint();
        mTickColor = typeArray.getColor(R.styleable.SubmitButton_sub_btn_tick_color,
                ContextCompat.getColor(getContext(), R.color.white));
        mTickPaint.setColor(mTickColor);
        mTickPaint.setStyle(Paint.Style.STROKE);
        mRipplePaint = new Paint();
        int mRippleColor = typeArray.getColor(R.styleable.SubmitButton_sub_btn_ripple_color,
                ContextCompat.getColor(getContext(), R.color.sub_btn_ripple));
        mRipplePaint.setColor(mRippleColor);
        mRipplePaint.setAntiAlias(true);
        mRippleDuration = typeArray.getInt(R.styleable.SubmitButton_sub_btn_duration,200) / 6;
        mInitTextColor = getCurrentTextColor();
        typeArray.recycle();
    }
 
Example #22
Source File: MCTileProvider.java    From blocktopograph with GNU Affero General Public License v3.0 5 votes vote down vote up
public static Bitmap drawText(String text, Bitmap b, int textColor, int bgColor) {
    // Get text dimensions
    TextPaint textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.LINEAR_TEXT_FLAG);
    textPaint.setStyle(Paint.Style.FILL);
    textPaint.setColor(textColor);
    textPaint.setTextSize(b.getHeight() / 16f);
    StaticLayout mTextLayout = new StaticLayout(text, textPaint, b.getWidth() / 2, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);

    // Create bitmap and canvas to draw to
    Canvas c = new Canvas(b);

    if(bgColor != 0){
        // Draw background
        Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.LINEAR_TEXT_FLAG);
        paint.setStyle(Paint.Style.FILL);
        paint.setColor(bgColor);
        c.drawPaint(paint);
    }

    // Draw text
    c.save();
    c.translate(0, 0);
    mTextLayout.draw(c);
    c.restore();

    return b;
}
 
Example #23
Source File: LayoutLoadingView.java    From Readhub with Apache License 2.0 5 votes vote down vote up
public LayoutLoadingView(Context context, AttributeSet attrs) {
    super(context, attrs);
    //添加文字的画加入以下代码
    mPaintText = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaintText.setColor(ContextCompat.getColor(context, android.R.color.white));
    mPaintText.setTextSize(20F);
    mPaintText.setTextAlign(Paint.Align.CENTER);
    paint1 = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint2 = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint1.setColor(color1);
    paint2.setColor(color2);

}
 
Example #24
Source File: MaterialProgressDrawable.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
public Ring(Callback callback) {
    mCallback = callback;

    mPaint.setStrokeCap(Paint.Cap.SQUARE);
    mPaint.setAntiAlias(true);
    mPaint.setStyle(Style.STROKE);

    mArrowPaint.setStyle(Style.FILL);
    mArrowPaint.setAntiAlias(true);
}
 
Example #25
Source File: ClippingImageView.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public ClippingImageView(Context context) {
    super(context);
    paint = new Paint(Paint.FILTER_BITMAP_FLAG);
    paint.setFilterBitmap(true);
    matrix = new Matrix();
    drawRect = new RectF();
    bitmapRect = new RectF();
    roundPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);

    roundRect = new RectF();
    shaderMatrix = new Matrix();
}
 
Example #26
Source File: FpsMeter.java    From OpenCvFaceDetect with Apache License 2.0 5 votes vote down vote up
public void init() {
    mFramesCouner = 0;
    mFrequency = Core.getTickFrequency();
    mprevFrameTime = Core.getTickCount();
    mStrfps = "";

    mPaint = new Paint();
    mPaint.setColor(Color.BLUE);
    mPaint.setTextSize(20);
}
 
Example #27
Source File: LabelGraphic.java    From quickstart-android with Apache License 2.0 5 votes vote down vote up
LabelGraphic(GraphicOverlay overlay, List<String> labels) {
  super(overlay);
  this.overlay = overlay;
  this.labels = labels;
  textPaint = new Paint();
  textPaint.setColor(Color.WHITE);
  textPaint.setTextSize(60.0f);
}
 
Example #28
Source File: AMCanvasCompat.java    From ProjectX with Apache License 2.0 5 votes vote down vote up
@Override
public void drawOval(Canvas canvas, float left, float top, float right, float bottom,
                     Paint paint) {
    final RectF oval = get();
    oval.set(left, top, right, bottom);
    canvas.drawOval(oval, paint);
    put(oval);
}
 
Example #29
Source File: PictureRendererStrategy.java    From SVG-Android with Apache License 2.0 5 votes vote down vote up
private void updateCachedPicture(int width, int height, ColorFilter filter) {
    Canvas canvas = mCachedPicture.beginRecording(width, height);
    Paint paint = getPaint(filter);
    if (paint != null) {
        canvas.drawPaint(paint);
    }
    mRenderer.render(canvas, width, height, null);
    mCachedPicture.endRecording();
}
 
Example #30
Source File: AbstractCustomVirtualView.java    From input-samples with Apache License 2.0 5 votes vote down vote up
protected AbstractCustomVirtualView(Context context, AttributeSet attrs, int defStyleAttr,
        int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);
    mTextPaint = new Paint();
    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CustomVirtualView,
            defStyleAttr, defStyleRes);
    int defaultHeight =
            (int) (DEFAULT_TEXT_HEIGHT_DP * getResources().getDisplayMetrics().density);
    mTextHeight = typedArray.getDimensionPixelSize(
            R.styleable.CustomVirtualView_internalTextSize, defaultHeight);
    typedArray.recycle();
    resetCoordinates();
}