Java Code Examples for android.text.TextPaint.setStrokeWidth()

The following are Jave code examples for showing how to use setStrokeWidth() of the android.text.TextPaint class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: BilibiliClient   File: OutlineTextView.java   Source Code and License Vote up 6 votes
private void initPaint() {

    mTextPaint = new TextPaint();
    mTextPaint.setAntiAlias(true);
    mTextPaint.setTextSize(getTextSize());
    mTextPaint.setColor(mColor);
    mTextPaint.setStyle(Paint.Style.FILL);
    mTextPaint.setTypeface(getTypeface());

    mTextPaintOutline = new TextPaint();
    mTextPaintOutline.setAntiAlias(true);
    mTextPaintOutline.setTextSize(getTextSize());
    mTextPaintOutline.setColor(mBorderColor);
    mTextPaintOutline.setStyle(Paint.Style.STROKE);
    mTextPaintOutline.setTypeface(getTypeface());
    mTextPaintOutline.setStrokeWidth(mBorderSize);
  }
 
Example 2
Project: Raffler-Android   File: CustomTextView.java   Source Code and License Vote up 6 votes
@Override
public void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    int restoreColor = this.getCurrentTextColor();
    if (strokeColor != null) {
        TextPaint paint = this.getPaint();
        paint.setStyle(Paint.Style.STROKE);
        paint.setStrokeJoin(strokeJoin);
        paint.setStrokeMiter(strokeMiter);
        this.setTextColor(strokeColor);
        paint.setStrokeWidth(strokeWidth);
        super.onDraw(canvas);
        paint.setStyle(Paint.Style.FILL);
        this.setTextColor(restoreColor);
    }
}
 
Example 3
Project: TPlayer   File: OutlineTextView.java   Source Code and License Vote up 6 votes
private void initPaint() {
  mTextPaint = new TextPaint();
  mTextPaint.setAntiAlias(true);
  mTextPaint.setTextSize(getTextSize());
  mTextPaint.setColor(mColor);
  mTextPaint.setStyle(Paint.Style.FILL);
  mTextPaint.setTypeface(getTypeface());

  mTextPaintOutline = new TextPaint();
  mTextPaintOutline.setAntiAlias(true);
  mTextPaintOutline.setTextSize(getTextSize());
  mTextPaintOutline.setColor(mBorderColor);
  mTextPaintOutline.setStyle(Paint.Style.STROKE);
  mTextPaintOutline.setTypeface(getTypeface());
  mTextPaintOutline.setStrokeWidth(mBorderSize);
}
 
Example 4
Project: QuanMinTV   File: OutlineTextView.java   Source Code and License Vote up 6 votes
private void initPaint() {
  mTextPaint = new TextPaint();
  mTextPaint.setAntiAlias(true);
  mTextPaint.setTextSize(getTextSize());
  mTextPaint.setColor(mColor);
  mTextPaint.setStyle(Paint.Style.FILL);
  mTextPaint.setTypeface(getTypeface());

  mTextPaintOutline = new TextPaint();
  mTextPaintOutline.setAntiAlias(true);
  mTextPaintOutline.setTextSize(getTextSize());
  mTextPaintOutline.setColor(mBorderColor);
  mTextPaintOutline.setStyle(Paint.Style.STROKE);
  mTextPaintOutline.setTypeface(getTypeface());
  mTextPaintOutline.setStrokeWidth(mBorderSize);
}
 
Example 5
Project: android-slidr   File: Sushi.java   Source Code and License Vote up 6 votes
public Settings(Sushi slidr) {
    this.slidr = slidr;

    paintBar = new Paint();
    paintBar.setAntiAlias(true);
    paintBar.setStrokeWidth(2);
    paintBar.setColor(colorBackground);

    paintTextTop = new TextPaint();
    paintTextTop.setAntiAlias(true);
    paintTextTop.setStyle(Paint.Style.FILL);
    paintTextTop.setColor(textColor);
    paintTextTop.setTextSize(dpToPx(textSize));

    paintTextBubble = new TextPaint();
    paintTextBubble.setAntiAlias(true);
    paintTextBubble.setStyle(Paint.Style.FILL);
    paintTextBubble.setColor(Color.WHITE);
    paintTextBubble.setStrokeWidth(2);
    paintTextBubble.setTextSize(dpToPx(textSizeBubble));

    paintBubble = new Paint();
    paintBubble.setAntiAlias(true);
    paintBubble.setStrokeWidth(3);
}
 
Example 6
Project: LuaViewPlayground   File: WeightStyleSpan.java   Source Code and License Vote up 5 votes
@Override
public void updateDrawState(TextPaint paint) {
    final float newStrokeWidth = (mWeight / (UDFontWeight.WEIGHT_NORMAL_INT + 0.0f));
    if (paint.getStyle() == Paint.Style.FILL) {
        paint.setStyle(Paint.Style.FILL_AND_STROKE);
    }
    paint.setStrokeWidth(newStrokeWidth);
}
 
Example 7
Project: Building-Android-UIs-with-Custom-Views   File: PrimitiveDrawer.java   Source Code and License Vote up 5 votes
public PrimitiveDrawer(Context context, AttributeSet attributeSet) {
    super(context, attributeSet);

    paint = new TextPaint();
    paint.setStyle(Paint.Style.FILL);
    paint.setAntiAlias(true);
    paint.setColor(0xffffffff);
    paint.setStrokeWidth(1.f);
    paint.setTextSize(35.f);
    paint.setTextAlign(Paint.Align.LEFT);
}
 
Example 8
Project: aos-Video   File: SubtitleTextView.java   Source Code and License Vote up 5 votes
@Override
protected void onDraw(Canvas canvas) {
    Canvas c = canvas;
    if (mExternalSurface != null) {
        try {
            canvas.getClipBounds(r);
            getLocationOnScreen(location);
            r.offsetTo(location[0],location[1]);
            c = mExternalSurface.lockCanvas(null);
            c.save();
            c.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
            c.clipRect(r);
            c.translate(location[0],location[1]);
        } catch (Exception ignored) {
        }
    }
    TextPaint paint = getPaint();
    int color = getCurrentTextColor();
    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeJoin(Paint.Join.MITER);
    paint.setStrokeMiter(1.0f);
    paint.setStrokeWidth(4.0f);
    setTextColor(Color.BLACK);
    super.onDraw(c);
    paint.setStyle(Paint.Style.FILL);
    setTextColor(color);
    super.onDraw(c);
    if (c != canvas) {
        c.restore();
        mExternalSurface.unlockCanvasAndPost(c);
    }
}
 
Example 9
Project: FastTextView   File: StrokeSpan.java   Source Code and License Vote up 5 votes
@Override
public void updateDrawState(TextPaint tp) {
  if (mDrawStroke) {
    tp.setColor(mStrokeColor);
    tp.setStrokeCap(Paint.Cap.ROUND);
    tp.setStrokeWidth(mStrokeWidth);
    tp.setStyle(Paint.Style.STROKE);
  } else {
    tp.setColor(mTextColor);
    tp.setStyle(Paint.Style.FILL);
  }
}
 
Example 10
Project: android-slidr   File: Slidr.java   Source Code and License Vote up 5 votes
public Settings(Slidr slidr) {
    this.slidr = slidr;

    paintIndicator = new Paint();
    paintIndicator.setAntiAlias(true);
    paintIndicator.setStrokeWidth(2);

    paintBar = new Paint();
    paintBar.setAntiAlias(true);
    paintBar.setStrokeWidth(2);
    paintBar.setColor(colorBackground);

    paintStep = new Paint();
    paintStep.setAntiAlias(true);
    paintStep.setStrokeWidth(5);
    paintStep.setColor(colorStoppover);

    paintTextTop = new TextPaint();
    paintTextTop.setAntiAlias(true);
    paintTextTop.setStyle(Paint.Style.FILL);
    paintTextTop.setColor(textColor);
    paintTextTop.setTextSize(textTopSize);

    paintTextBottom = new TextPaint();
    paintTextBottom.setAntiAlias(true);
    paintTextBottom.setStyle(Paint.Style.FILL);
    paintTextBottom.setColor(textColor);
    paintTextBottom.setTextSize(textBottomSize);

    paintBubbleTextCurrent = new TextPaint();
    paintBubbleTextCurrent.setAntiAlias(true);
    paintBubbleTextCurrent.setStyle(Paint.Style.FILL);
    paintBubbleTextCurrent.setColor(Color.WHITE);
    paintBubbleTextCurrent.setStrokeWidth(2);
    paintBubbleTextCurrent.setTextSize(dpToPx(textSizeBubbleCurrent));

    paintBubble = new Paint();
    paintBubble.setAntiAlias(true);
    paintBubble.setStrokeWidth(3);
}
 
Example 11
Project: live_master   File: AndroidDisplayer.java   Source Code and License Vote up 5 votes
public AndroidDisplayer() {
    PAINT = new TextPaint();
    PAINT.setStrokeWidth(STROKE_WIDTH);
    PAINT_DUPLICATE = new TextPaint(PAINT);
    ALPHA_PAINT = new Paint();
    UNDERLINE_PAINT = new Paint();
    UNDERLINE_PAINT.setStrokeWidth(UNDERLINE_HEIGHT);
    UNDERLINE_PAINT.setStyle(Style.STROKE);
    BORDER_PAINT = new Paint();
    BORDER_PAINT.setStyle(Style.STROKE);
    BORDER_PAINT.setStrokeWidth(BORDER_WIDTH);
}
 
Example 12
Project: QuranKeyboard   File: CandidateView.java   Source Code and License Vote up 4 votes
/**
 * Construct a CandidateView for showing suggested words for completion.
 * @param context context
 */
public CandidateView(Context context) {
    super(context);
    mService = (QuranKeyboardIME) context;

    mSelectionHighlight = ContextCompat.getDrawable(context,
            android.R.drawable.list_selector_background);
    mSelectionHighlight.setState(new int[] {
            android.R.attr.state_enabled,
            android.R.attr.state_focused,
            android.R.attr.state_window_focused,
            android.R.attr.state_pressed
    });

    Resources r = context.getResources();
    
    setBackgroundColor(ContextCompat.getColor(context, R.color.candidate_background));
    
    mColorNormal = ContextCompat.getColor(context, R.color.candidate_normal);
    mColorRecommended = ContextCompat.getColor(context, R.color.candidate_recommended);
    mColorOther = ContextCompat.getColor(context, R.color.candidate_other);
    mVerticalPadding = r.getDimensionPixelSize(R.dimen.candidate_vertical_padding);

    mPaint = new TextPaint();
    mPaint.setColor(mColorNormal);
    mPaint.setAntiAlias(true);
    mPaint.setTextSize(r.getDimensionPixelSize(R.dimen.candidate_font_height));
    mPaint.setStrokeWidth(0);
    mDefaultTf = mPaint.getTypeface();
    mUthamniTf = mService.getUthmaniTypeFace();

    mGestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
        @Override
        public boolean onScroll(MotionEvent e1, MotionEvent e2,
                float distanceX, float distanceY) {
            mScrolled = true;
            int sx = getScrollX();
            sx += distanceX;
            if (sx < 0) {
                sx = 0;
            }
            if (sx + getWidth() > mTotalWidth) {                    
                sx -= distanceX;
            }
            mTargetScrollX = sx;
            scrollTo(sx, getScrollY());
            invalidate();
            return true;
        }
    });
    setHorizontalFadingEdgeEnabled(true);
    setWillNotDraw(false);
    setHorizontalScrollBarEnabled(false);
    setVerticalScrollBarEnabled(false);
}