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

The following examples show how to use android.text.TextPaint#setStrokeWidth() . 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: OutlineTextView.java    From BambooPlayer with Apache License 2.0 8 votes vote down vote up
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
Source File: OutlineTextView.java    From NetEasyNews with GNU General Public License v3.0 6 votes vote down vote up
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 3
Source File: OutlineTextView.java    From Vitamio with Apache License 2.0 6 votes vote down vote up
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
Source File: OutlineTextView.java    From mobile-manager-tool with MIT License 6 votes vote down vote up
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
Source File: OutlineTextView.java    From video-player with MIT License 6 votes vote down vote up
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 6
Source File: OutlineTextView.java    From BambooPlayer with Apache License 2.0 6 votes vote down vote up
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 7
Source File: OutlineTextView.java    From HPlayer with Apache License 2.0 6 votes vote down vote up
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 8
Source File: OutlineTextView.java    From MyHearts with Apache License 2.0 6 votes vote down vote up
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 9
Source File: OutlineTextView.java    From react-native-android-vitamio with MIT License 6 votes vote down vote up
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 10
Source File: Sushi.java    From android-slidr with Apache License 2.0 6 votes vote down vote up
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 11
Source File: StrokeSpan.java    From FastTextView with Apache License 2.0 5 votes vote down vote up
@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 12
Source File: CustomClickTopicSpan.java    From GSYRickText with MIT License 5 votes vote down vote up
@Override
public void updateDrawState(TextPaint ds) {
    super.updateDrawState(ds);
    ds.setUnderlineText(true);
    ds.setStyle(Paint.Style.FILL_AND_STROKE);
    PathEffect effects = new DashPathEffect(new float[]{1, 1}, 1);
    ds.setPathEffect(effects);
    ds.setStrokeWidth(2);
}
 
Example 13
Source File: Slidr.java    From android-slidr with Apache License 2.0 5 votes vote down vote up
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 14
Source File: MediaStrokeTextView.java    From FimiX8-RE with MIT License 5 votes vote down vote up
public void init() {
    TextPaint tp1 = this.borderText.getPaint();
    tp1.setStrokeWidth(1.0f);
    tp1.setStyle(Style.STROKE);
    this.borderText.setTextColor(1275068416);
    this.borderText.setGravity(getGravity());
}
 
Example 15
Source File: PrimitiveDrawer.java    From Building-Android-UIs-with-Custom-Views with MIT License 5 votes vote down vote up
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 16
Source File: SubtitleLayer.java    From PhotoMovie with Apache License 2.0 5 votes vote down vote up
private Bitmap genBitmapFromStr(String str, TextPaint textPaint, float density) {
        if (TextUtils.isEmpty(str)) {
            return null;
        }

        Paint.FontMetrics fontMetrics = textPaint.getFontMetrics();
        int h = (int) (Math.abs(fontMetrics.ascent) + Math.abs(fontMetrics.descent));
        int w = (int) textPaint.measureText(str);
        Bitmap bitmap = PhotoUtil.createBitmapOrNull(w, h, Bitmap.Config.ARGB_4444);
        if (bitmap == null) {
            return null;
        }
        Canvas canvas = new Canvas(bitmap);
        // 描外层
        textPaint.setColor(0xFF343434);
        textPaint.setStrokeWidth(density * STROKE_WIDTH_DP + 0.5f);  // 描边宽度
        textPaint.setStyle(Paint.Style.FILL_AND_STROKE); //描边种类
        textPaint.setFakeBoldText(true); // 外层text采用粗体
//        textPaint.setShadowLayer(1, 0, 0, 0); //字体的阴影效果,可以忽略
        canvas.drawText(str, 0, Math.abs(fontMetrics.ascent), textPaint);

        // 描内层,恢复原先的画笔
        textPaint.setColor(0xFFFFFFFF);
        textPaint.setStrokeWidth(0);
        textPaint.setStyle(Paint.Style.FILL_AND_STROKE);
        textPaint.setFakeBoldText(false);
//        textPaint.setShadowLayer(0, 0, 0, 0);
        canvas.drawText(str, 0, Math.abs(fontMetrics.ascent), textPaint);

        return bitmap;
    }
 
Example 17
Source File: WeightStyleSpan.java    From VideoOS-Android-SDK with GNU General Public License v3.0 5 votes vote down vote up
@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 18
Source File: X8MiLantingStrokeTextView.java    From FimiX8-RE with MIT License 5 votes vote down vote up
public void init(Context mContext) {
    TextPaint tp1 = this.borderText.getPaint();
    tp1.setStrokeWidth(1.0f);
    tp1.setStyle(Style.STROKE);
    this.borderText.setTextColor(855638016);
    this.borderText.setGravity(getGravity());
    FontUtil.changeFontLanTing(mContext.getAssets(), this.borderText, this);
}
 
Example 19
Source File: ThinBoldSpan.java    From CloudReader with Apache License 2.0 4 votes vote down vote up
@Override
public void updateDrawState(TextPaint tp) {
    tp.setStyle(Paint.Style.FILL_AND_STROKE);
    //控制字体加粗的程度
    tp.setStrokeWidth(dpToPx(context, f));
}
 
Example 20
Source File: SystemText.java    From remixed-dungeon with GNU General Public License v3.0 4 votes vote down vote up
public SystemText(final String text, float size, boolean multiline) {
	super(0, 0, 0, 0);

	if (fontScale != fontScale) {
		updateFontScale();
	}

	if (tf == null) {
		if (Game.smallResScreen()) {
			tf = Typeface.create((String) null, Typeface.BOLD);
			oversample = 1;
		} else {
			tf = Typeface.create((String) null, Typeface.NORMAL);
			oversample = 4;
		}
	}

	size *= fontScale;

	needWidth = multiline;

	if (size == 0) {
		throw new TrackedRuntimeException("zero sized font!!!");
	}

	float textSize = size * oversample;
	if (!textPaints.containsKey(textSize)) {
		TextPaint tx = new TextPaint();

		tx.setTextSize(textSize);
		tx.setStyle(Paint.Style.FILL_AND_STROKE);
		tx.setHinting(Paint.HINTING_ON);
		tx.setAntiAlias(true);

		tx.setColor(Color.WHITE);

		tx.setTypeface(tf);

		TextPaint cp = new TextPaint();
		cp.set(tx);
		cp.setStyle(Paint.Style.FILL_AND_STROKE);
		cp.setStrokeWidth(textSize * 0.2f);
		cp.setColor(Color.BLACK);
		cp.setAntiAlias(true);

		textPaints.put(textSize, tx);
		contourPaints.put(textSize, cp);
	}

	textPaint = textPaints.get(textSize);
	contourPaint = contourPaints.get(textSize);

	this.text(text);
	texts.add(this);
}