Create Paint from text and font size - Android android.graphics

Android examples for android.graphics:Paint

Description

Create Paint from text and font size

Demo Code

import android.graphics.Paint;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main{

    public static int GetPixelByText(float textSize, String text) {
        Paint mTextPaint = new Paint();
        mTextPaint.setTextSize(textSize); 
        mTextPaint.setFakeBoldText(true); 
        mTextPaint.setAntiAlias(true); //from  ww w. jav a  2  s .  c  o m

        return (int) (mTextPaint.measureText(text) + textSize);
    }

}

Related Tutorials