Java Code Examples for android.graphics.Paint#setUnderlineText()

The following examples show how to use android.graphics.Paint#setUnderlineText() . 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: BorderedSpan.java    From tindroid with Apache License 2.0 6 votes vote down vote up
@Override
public void draw(@NonNull Canvas canvas, CharSequence text,
                 int start, int end, float x, int top, int y, int bottom, @NonNull Paint paint) {
    RectF outline = new RectF(x, top, x + mWidth * mDipSize, top + mButtonHeight * mDipSize);
    outline.inset(SHADOW_SIZE * mDipSize, SHADOW_SIZE * mDipSize);
    // Draw colored background
    canvas.drawRoundRect(outline, RADIUS_CORNER * mDipSize, RADIUS_CORNER * mDipSize, mPaintBackground);

    // Don't underline the text.
    paint.setUnderlineText(false);
    paint.setColor(mTextColor);
    canvas.drawText(text, start, end,
            x + (mWidth - mWidthActual) * mDipSize * 0.5f,
            top + (mButtonHeight * mDipSize - paint.ascent() - paint.descent()) * 0.5f,
            paint);
}
 
Example 2
Source File: TextGraphic.java    From Android-face-filters with Apache License 2.0 5 votes vote down vote up
public static Bitmap drawTextBitmap(String string, int color, int alpha, int size, boolean underline, int width , int height) {
    Bitmap result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(result);
    //canvas.drawBitmap();
    Paint paint = new Paint();
    paint.setColor(color);
    paint.setAlpha(alpha);
    paint.setTextSize(size);
    paint.setAntiAlias(true);
    paint.setUnderlineText(underline);
    canvas.drawText(string, 100, 150, paint);
    return result;
}
 
Example 3
Source File: Font.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
public Font(Typeface face, int style, float size, boolean underline) {
	if (applyDimensions) {
		size = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, size,
				ContextHolder.getAppContext().getResources().getDisplayMetrics());
	}

	paint = new Paint();

	paint.setTypeface(Typeface.create(face, style));
	paint.setUnderlineText(underline);

	paint.setTextSize(size);                                             // at first, just set the size (no matter what is put here)
	paint.setTextSize(size * size / (paint.descent() - paint.ascent())); // and now we set the size equal to the given one (in pixels)
}
 
Example 4
Source File: MarkwonTheme.java    From Markwon with Apache License 2.0 5 votes vote down vote up
public void applyLinkStyle(@NonNull Paint paint) {
    paint.setUnderlineText(true);
    if (linkColor != 0) {
        // by default we will be using text color
        paint.setColor(linkColor);
    } else {
        // @since 1.0.5, if link color is specified during configuration, _try_ to use the
        // default one (if provided paint is an instance of TextPaint)
        if (paint instanceof TextPaint) {
            paint.setColor(((TextPaint) paint).linkColor);
        }
    }
}
 
Example 5
Source File: XulSpannedLabelRender.java    From starcor.xul with GNU Lesser General Public License v3.0 5 votes vote down vote up
private Paint _getTextPaint(float fontSizeScale) {
	Paint defPaint = _ctx.getTextPaintByName(_fontFace);

	if (!(_fontShadowSize == 0 || (_fontShadowColor & 0xFF000000) == 0)) {
		defPaint = _ctx.getShadowTextPaintByName(_fontFace);
		defPaint.setShadowLayer(_fontShadowSize, _fontShadowX, _fontShadowY, _fontShadowColor);
	}

	defPaint.setColor(_fontColor);
	if (Math.abs(fontSizeScale - 1.0f) > 0.01f) {
		defPaint.setTextSize(_fontSize * fontSizeScale);
	} else {
		defPaint.setTextSize(_fontSize);
	}

	//defPaint.setStrokeWidth(_fontWeight / 2.0f);

	if (_fontWeight > 1.0) {
		defPaint.setFakeBoldText(true);
	} else {
		defPaint.setFakeBoldText(false);
	}
	defPaint.setUnderlineText(_fontUnderline);
	defPaint.setTextSkewX(_fontItalic ? -0.25f : 0);
	defPaint.setTextAlign(Paint.Align.LEFT);
	return defPaint;
}
 
Example 6
Source File: XulBasicTextRenderer.java    From starcor.xul with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected Paint _getTextPaint(float fontSizeScale) {
	XulRenderContext ctx = _render.getRenderContext();
	Paint defPaint = ctx.getTextPaintByName(_fontFace);

	if (!(_fontShadowSize == 0 || (_fontShadowColor & 0xFF000000) == 0)) {
		defPaint = ctx.getShadowTextPaintByName(_fontFace);
		defPaint.setShadowLayer(_fontShadowSize, _fontShadowX, _fontShadowY, _fontShadowColor);
	}

	defPaint.setColor(_fontColor);
	if (Math.abs(fontSizeScale - 1.0f) > 0.01f) {
		defPaint.setTextSize(_fontSize * fontSizeScale);
	} else {
		defPaint.setTextSize(_fontSize);
	}

	if (_fontWeight > 1.0) {
		if (_fontWeight > 2.5) {
			defPaint.setStrokeWidth(_fontWeight*fontSizeScale/2);
		} else {
			defPaint.setFakeBoldText(true);
		}
	} else {
		defPaint.setFakeBoldText(false);
	}
	defPaint.setTextScaleX(_fontScaleX);
	defPaint.setUnderlineText(_fontUnderline);
	defPaint.setStrikeThruText(_fontStrikeThrough);
	defPaint.setTextSkewX(_fontItalic ? -0.25f : 0);
	defPaint.setTextAlign(Paint.Align.LEFT);
	return defPaint;
}
 
Example 7
Source File: SpannableBuilder.java    From AndroidCommons with Apache License 2.0 5 votes vote down vote up
private void apply(Paint paint) {
    if (style.typeface != null) {
        paint.setTypeface(style.typeface);
    }
    if (style.color != Style.NO_COLOR) {
        paint.setColor(style.color);
    }
    if (style.size != Style.NO_SIZE) {
        paint.setTextSize(style.size);
    }
    paint.setUnderlineText(style.underline);
}
 
Example 8
Source File: Font.java    From J2ME-Loader with Apache License 2.0 4 votes vote down vote up
public void copyInto(Paint target) {
	target.setTypeface(paint.getTypeface());
	target.setUnderlineText(paint.isUnderlineText());
	target.setTextSize(paint.getTextSize());
}