Example usage for android.graphics Paint setUnderlineText

List of usage examples for android.graphics Paint setUnderlineText

Introduction

In this page you can find the example usage for android.graphics Paint setUnderlineText.

Prototype

public void setUnderlineText(boolean underlineText) 

Source Link

Document

Helper for setFlags(), setting or clearing the UNDERLINE_TEXT_FLAG bit

Usage

From source file:es.javocsoft.android.lib.toolbox.ToolBox.java

public static Bitmap graphics_addWaterMarkToImage(Bitmap src, String watermark, Point location, int size,
        boolean underline) {
    Bitmap result = null;//from   w  ww  . j a va 2s.  co m

    try {
        int w = src.getWidth();
        int h = src.getHeight();
        result = Bitmap.createBitmap(w, h, src.getConfig());

        Canvas canvas = new Canvas(result);
        canvas.drawBitmap(src, 0, 0, null);

        Paint paint = new Paint();
        paint.setColor(Color.RED);
        //paint.setAlpha(alpha);
        paint.setTextSize(size);
        paint.setAntiAlias(true);
        paint.setUnderlineText(underline);
        canvas.drawText(watermark, location.x, location.y, paint);
    } catch (Exception e) {
        result = null;
        if (LOG_ENABLE)
            Log.e(TAG, "ERROR: graphics_addWaterMarkToImage() [" + e.getMessage() + "]", e);
    }

    return result;
}

From source file:com.codename1.impl.android.AndroidImplementation.java

@Override
public Object createFont(int face, int style, int size) {
    Typeface typeface = null;//from w  w w.  ja v a 2  s  . c o m
    switch (face) {
    case Font.FACE_MONOSPACE:
        typeface = Typeface.MONOSPACE;
        break;
    default:
        typeface = Typeface.DEFAULT;
        break;
    }

    int fontstyle = Typeface.NORMAL;
    if ((style & Font.STYLE_BOLD) != 0) {
        fontstyle |= Typeface.BOLD;
    }
    if ((style & Font.STYLE_ITALIC) != 0) {
        fontstyle |= Typeface.ITALIC;
    }

    int height = this.defaultFontHeight;
    int diff = height / 3;

    switch (size) {
    case Font.SIZE_SMALL:
        height -= diff;
        break;
    case Font.SIZE_LARGE:
        height += diff;
        break;
    }

    Paint font = new CodenameOneTextPaint(Typeface.create(typeface, fontstyle));
    font.setAntiAlias(true);
    font.setUnderlineText((style & Font.STYLE_UNDERLINED) != 0);
    font.setTextSize(height);
    return new NativeFont(face, style, size, font);

}