Code example for TextPaint

Methods: setColorsetFakeBoldTextsetStrokeWidthsetTextAlignsetTextSize

0
import android.util.Log; 
import android.view.View; 
import android.view.ViewGroup; 
 
public class Pager extends View {
    private TextPaint paint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
    private int currentPage = -1;
    private int totalPages = -1;
 
    public static final int WIDTH = SmartWatchControl.WIDTH;
    public static final int HEIGHT = 8;
    private static final int X = 0;
    private static final int Y = 0;
    private static final float MARGIN = 30f;
 
    public Pager(Context context) {
        this(context, null);
    } 
 
    public Pager(Context context, AttributeSet attrs) {
        super(context, attrs);
        layout(0, 0, WIDTH, HEIGHT);
        paint.setColor(Color.parseColor("#ffdad8d4"));
        paint.setTextSize(10f);
        paint.setTextAlign(Paint.Align.CENTER);
        paint.setFakeBoldText(true);
        paint.setStrokeWidth(3f);
    } 
 
    @Override 
    protected void onDraw(Canvas canvas) {
        if (currentPage >= 0 && totalPages >= 0) {