FileDocCategorySizeDatePackage
BiDiTestViewDrawText.javaAPI DocAndroid 5.1 API2208Thu Mar 12 22:22:42 GMT 2015com.android.bidi

BiDiTestViewDrawText

public class BiDiTestViewDrawText extends android.view.View

Fields Summary
private float
mSize
private int
mColor
private String
mText
Constructors Summary
public BiDiTestViewDrawText(android.content.Context context)

        this(context, null);
    
public BiDiTestViewDrawText(android.content.Context context, android.util.AttributeSet attrs)

        this(context, attrs, 0);
    
public BiDiTestViewDrawText(android.content.Context context, android.util.AttributeSet attrs, int defStyle)

        super(context, attrs, defStyle);

        final TypedArray a = context.obtainStyledAttributes(attrs,
                R.styleable.DrawTextTestView, defStyle, 0);
        mSize = a.getDimension(R.styleable.DrawTextTestView_size, 40.0f);
        mColor = a.getColor(R.styleable.DrawTextTestView_color, Color.YELLOW);
        final CharSequence text = a.getText(R.styleable.DrawTextTestView_text);
        mText = (text != null) ? text.toString() : "(empty)";
        a.recycle();
    
Methods Summary
protected voidonDraw(android.graphics.Canvas canvas)

        super.onDraw(canvas);
        final int width = getWidth();
        final int height = getHeight();

        final TextPaint paint = new TextPaint();
        paint.setTextSize(mSize);
        paint.setColor(mColor);
        paint.setTextAlign(Align.CENTER);

        canvas.drawText(mText, width / 2, height * 2 / 3, paint);