Java Code Examples for android.graphics.Paint.setLetterSpacing()

The following are Jave code examples for showing how to use setLetterSpacing() 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: SmingZZick_App   File: TextMakingInfo.java   View Source Code Vote up 5 votes
public Paint getPaint(Context context, float scale, boolean outline) {
    float textSize = TypedValue.applyDimension(
            TypedValue.COMPLEX_UNIT_DIP,
            this.textSize,
            context.getResources().getDisplayMetrics()) * scale;

    Paint textPaint = new Paint();

    if (typeface != null) {
        textPaint.setTypeface(typeface);
    }

    textPaint.setStyle(Paint.Style.FILL_AND_STROKE);
    textPaint.setTextSize(textSize);
    textPaint.setAntiAlias(true);

    if (outline == false) {
        textPaint.setStrokeWidth(textSize * textStrokeRatio);
        textPaint.setColor(textColor);
    } else {
        textPaint.setStrokeWidth(textSize * textStrokeRatio + textSize * textOutlineRatio);
        textPaint.setColor(outlineColor);
    }


    // skew
    textPaint.setTextSkewX(skewX);


    // scaleX
    textPaint.setTextScaleX(scaleX);

    if (Build.VERSION.SDK_INT >= 21) {
        textPaint.setLetterSpacing(letterSpacing);
    }

    return textPaint;
}