Java Code Examples for android.graphics.Paint.Style

The following are Jave code examples for showing how to use Style of the android.graphics.Paint class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: gmlrva   File: SimpleDividerItemDecorationSpec.java   View Source Code Vote up 6 votes
/**
 * Procedure meant to set the value for {@link #mDrawnDivider} optional parameter.
 * @param color the divider's target {@link Color} value.
 *              See {@link Paint#setColor(int)} for more information.
 * @param thickness the divider's target line thickness value. This value must be greater or equal than 0.
 *                  See {@link Paint#setStrokeWidth(float)} for more information.
 * @param style the divider's target {@link Paint.Style}.
 *              See {@link Paint#setStyle(Paint.Style)} for more information.
 * @param pathEffect the divider's target {@link PathEffect}.
 *                   See {@link Paint#setPathEffect(PathEffect)} for more information.
 * @return the same object builder object after setting the optional attribute.
 */
@NonNull
public DecorationSpecBuilder withDrawnDivider(@ColorInt int color,
                                              @FloatRange(from = 0, fromInclusive = false) float thickness,
                                              @Nullable final Paint.Style style,
                                              @Nullable final PathEffect pathEffect) {
    mDrawnDivider = new Paint();
    mDrawnDivider.setColor(color);
    mDrawnDivider.setStrokeWidth(thickness);
    if (style != null) {
        mDrawnDivider.setStyle(style);
    }
    if (pathEffect != null) {
        mDrawnDivider.setPathEffect(pathEffect);
    }
    return this;
}
 
Example 2
Project: HeadlineNews   File: SpanUtils.java   View Source Code Vote up 6 votes
@Override
public void draw(@NonNull final Canvas canvas, final CharSequence text,
                 @IntRange(from = 0) final int start,
                 @IntRange(from = 0) final int end,
                 final float x, final int top, final int y, final int bottom,
                 @NonNull final Paint paint) {
    Paint.Style style = paint.getStyle();
    int color = paint.getColor();

    paint.setStyle(Paint.Style.FILL);
    paint.setColor(this.color);

    canvas.drawRect(x, top, x + width, bottom, paint);

    paint.setStyle(style);
    paint.setColor(color);
}
 
Example 3
Project: AndroidUtilCode-master   File: SpanUtils.java   View Source Code Vote up 5 votes
public void drawLeadingMargin(Canvas c, Paint p, int x, int dir,
                              int top, int baseline, int bottom,
                              CharSequence text, int start, int end,
                              boolean first, Layout layout) {
    Paint.Style style = p.getStyle();
    int color = p.getColor();

    p.setStyle(Paint.Style.FILL);
    p.setColor(this.color);

    c.drawRect(x, top, x + dir * stripeWidth, bottom, p);

    p.setStyle(style);
    p.setColor(color);
}
 
Example 4
Project: GitHub   File: LineRadarRenderer.java   View Source Code Vote up 5 votes
/**
 * Draws the provided path in filled mode with the provided color and alpha.
 * Special thanks to Angelo Suzuki (https://github.com/tinsukE) for this.
 *
 * @param c
 * @param filledPath
 * @param fillColor
 * @param fillAlpha
 */
protected void drawFilledPath(Canvas c, Path filledPath, int fillColor, int fillAlpha) {

    int color = (fillAlpha << 24) | (fillColor & 0xffffff);

    if (clipPathSupported()) {

        int save = c.save();

        c.clipPath(filledPath);

        c.drawColor(color);
        c.restoreToCount(save);
    } else {

        // save
        Paint.Style previous = mRenderPaint.getStyle();
        int previousColor = mRenderPaint.getColor();

        // set
        mRenderPaint.setStyle(Paint.Style.FILL);
        mRenderPaint.setColor(color);

        c.drawPath(filledPath, mRenderPaint);

        // restore
        mRenderPaint.setColor(previousColor);
        mRenderPaint.setStyle(previous);
    }
}
 
Example 5
Project: Markwon   File: TaskListDrawable.java   View Source Code Vote up 5 votes
@Override
public void draw(@NonNull Canvas canvas) {

    final Paint.Style style;
    final int color;

    if (isChecked) {
        style = Paint.Style.FILL_AND_STROKE;
        color = checkedFillColor;
    } else {
        style = Paint.Style.STROKE;
        color = normalOutlineColor;
    }
    paint.setStyle(style);
    paint.setColor(color);

    final Rect bounds = getBounds();

    final float left = (bounds.width() - rectF.width()) / 2;
    final float top = (bounds.height() - rectF.height()) / 2;

    final float radius = rectF.width() / 8;

    final int save = canvas.save();
    try {

        canvas.translate(left, top);

        canvas.drawRoundRect(rectF, radius, radius, paint);

        if (isChecked) {
            canvas.drawPath(checkMarkPath, checkMarkPaint);
        }
    } finally {
        canvas.restoreToCount(save);
    }
}
 
Example 6
Project: JZAndroidChart   File: CandlestickValue.java   View Source Code Vote up 5 votes
public CandlestickValue(float high, float low, float open, float close, Paint.Style mPaintStyle,
    int color) {
  this.high = high;
  this.low = low;
  this.open = open;
  this.close = close;
  this.mPaintStyle = mPaintStyle;
  this.color = color;
}
 
Example 7
Project: GitHub   File: BaseUtils.java   View Source Code Vote up 5 votes
public static Paint getPaint(Paint.Style style, int color) {
    Paint mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setStyle(style);
    mPaint.setColor(color);
    mPaint.setTextSize(30);
    return mPaint;
}
 
Example 8
Project: GitHub   File: SpanUtils.java   View Source Code Vote up 5 votes
public void drawLeadingMargin(final Canvas c, final Paint p, final int x, final int dir,
                              final int top, final int baseline, final int bottom,
                              final CharSequence text, final int start, final int end,
                              final boolean first, final Layout layout) {
    Paint.Style style = p.getStyle();
    int color = p.getColor();

    p.setStyle(Paint.Style.FILL);
    p.setColor(this.color);

    c.drawRect(x, top, x + dir * stripeWidth, bottom, p);

    p.setStyle(style);
    p.setColor(color);
}
 
Example 9
Project: Slide-RSS   File: CustomQuoteSpan.java   View Source Code Vote up 5 votes
@Override
public void drawLeadingMargin(Canvas c, Paint p, int x, int dir, int top, int baseline, int bottom,
                              CharSequence text, int start, int end, boolean first, Layout layout) {
    Paint.Style style = p.getStyle();
    int paintColor = p.getColor();

    p.setStyle(Paint.Style.FILL);
    p.setColor(stripeColor);

    c.drawRect(x, top, x + dir * stripeWidth, bottom, p);

    p.setStyle(style);
    p.setColor(paintColor);
}
 
Example 10
Project: MKClockView   File: MKAnalogClockView.java   View Source Code Vote up 4 votes
public Paint.Style getHourHandStyle() {
    return hourHandStyle;
}
 
Example 11
Project: GitHub   File: CandleDataSet.java   View Source Code Vote up 4 votes
@Override
public Paint.Style getDecreasingPaintStyle() {
    return mDecreasingPaintStyle;
}
 
Example 12
Project: mkloader   File: GraphicObject.java   View Source Code Vote up 4 votes
public void setStyle(Paint.Style style) {
  paint.setStyle(style);
}
 
Example 13
Project: JZAndroidChart   File: CandlestickDataSet.java   View Source Code Vote up 4 votes
public void setIncreasingPaintStyle(Paint.Style increasingPaintStyle) {
  this.mIncreasingPaintStyle = increasingPaintStyle;
}
 
Example 14
Project: JZAndroidChart   File: BarValue.java   View Source Code Vote up 4 votes
public BarValue(float value1, float value2, int color, Paint.Style paintStyle) {
    this.yValues = new float[] {value1, value2};
    this.mColor = color;
    this.mPaintStyle = paintStyle;
}
 
Example 15
Project: MKClockView   File: MKAnalogClockView.java   View Source Code Vote up 4 votes
public Paint.Style getSecondHandStyle() {
    return secondHandStyle;
}
 
Example 16
Project: JZAndroidChart   File: CandlestickValue.java   View Source Code Vote up 4 votes
public Paint.Style getPaintStyle() {
  return mPaintStyle;
}
 
Example 17
Project: MKClockView   File: MKAnalogClockView.java   View Source Code Vote up 4 votes
public void setCircleStyle(Paint.Style circleStyle) {
    this.circleStyle = circleStyle;
}
 
Example 18
Project: MKClockView   File: MKAnalogClockView.java   View Source Code Vote up 4 votes
public void setCenterStyle(Paint.Style centerStyle) {
    this.centerStyle = centerStyle;
}
 
Example 19
Project: JZAndroidChart   File: CandlestickDataSet.java   View Source Code Vote up 4 votes
public void setLimitUpPaintStyle(Paint.Style limitUpPaintStyle) {
  this.mLimitUpPaintStyle = limitUpPaintStyle;
}
 
Example 20
Project: GitHub   File: CandleDataSet.java   View Source Code Vote up 2 votes
/**
 * Sets paint style when open > close
 *
 * @param decreasingPaintStyle
 */
public void setDecreasingPaintStyle(Paint.Style decreasingPaintStyle) {
    this.mDecreasingPaintStyle = decreasingPaintStyle;
}