Paint setTextAlign - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Paint setTextAlign method.

This code example shows how to use the following methods:setColor, setStyle, setTextAlign, setTextSize
 
    // --- painting code 
 
    @Override 
    protected void onDraw(Canvas canvas) {
        Paint paint = new Paint();
        paint.setColor(BG_COLOR);
        paint.setStyle(Paint.Style.FILL);
        canvas.drawRect(0, 0, getWidth(), getHeight(), paint);
 
        paint.setColor(FILTER_COLOR);
        Path path = new Path();
        path.moveTo(getWidth() * (0.5f - 0.5f * start / max), 0);
        path.lineTo(getWidth() * (0.5f + 0.5f * start / max), 0);
        path.lineTo(getWidth() * (0.5f + 0.5f * end / max), getHeight());
        path.lineTo(getWidth() * (0.5f - 0.5f * end / max), getHeight());
        path.close();
        canvas.drawPath(path, paint);
 
        paint.setColor(TEXT_COLOR);

9
CodeRank
This code example shows how to use the following methods:getFontMetricsInt, measureText, setColor, setTextAlign, setTextSize
This code example shows how to use the following methods:setAntiAlias, setColor, setStyle, setTextAlign, setTextSize
        baseApi.end();
    } 
 
    private static Bitmap getTextImage(String text, int width, int height) {
        final Bitmap bmp = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
        final Paint paint = new Paint();
        final Canvas canvas = new Canvas(bmp);
 
        canvas.drawColor(Color.WHITE);
 
        paint.setColor(Color.BLACK);
        paint.setStyle(Style.FILL);
        paint.setAntiAlias(true);
        paint.setTextAlign(Align.CENTER);
        paint.setTextSize(24.0f);
        canvas.drawText(text, width / 2, height / 2, paint);
 
        return bmp;
    } 
 
8
CodeRank
This code example shows how to use the following methods:setAlpha, setAntiAlias, setColor, setFakeBoldText, setStyle
 
        init(); 
    } 
 
    private void init() { 
        mCirclePaint.setFakeBoldText(true);
        mCirclePaint.setAntiAlias(true);
        mCirclePaint.setColor(mCircleColor);
        mCirclePaint.setTextAlign(Align.CENTER);
        mCirclePaint.setStyle(Style.FILL);
        mCirclePaint.setAlpha(SELECTED_CIRCLE_ALPHA);
    } 
 
    public void drawIndicator(boolean drawCircle) {
        mDrawCircle = drawCircle;
    } 
 
    @Override 
    public void onDraw(Canvas canvas) {
        super.onDraw(canvas);
8
CodeRank
This code example shows how to use the following methods:setColor, setTextAlign, setTextSize
    protected void onDraw(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);
    } 
} 
8
CodeRank
This code example shows how to use the following methods:setAntiAlias, setColor, setTextAlign, setTextSize, setTypeface
    	 
    	return strList;
    } 
     
    private static Paint newPaint(String fontName, int fontSize, int alignment){
    	Paint paint = new Paint();
    	paint.setColor(Color.WHITE);
        paint.setTextSize(fontSize);      
        paint.setAntiAlias(true);    
         
        /* 
         * Set type face for paint, now it support .ttf file. 
         */ 
        if (fontName.endsWith(".ttf")){
        	 try { 
        		//Typeface typeFace = Typeface.createFromAsset(context.getAssets(), fontName); 
        		 Typeface typeFace = Cocos2dxTypefaces.get(context, fontName);
              	paint.setTypeface(typeFace);
             } catch (Exception e){
             	Log.e("Cocos2dxBitmap", 

8
CodeRank
This code example shows how to use the following methods:setAntiAlias, setColor, setFakeBoldText, setStyle, setTextAlign
This code example shows how to use the following methods:setAntiAlias, setColor, setStyle, setTextAlign, setTypeface
     * @param icon    The icon you want this drawable to display. 
     */ 
    public IconDrawable(Context context, Iconify.IconValue icon) {
        this.context = context;
        this.icon = icon;
        paint = new TextPaint();
        paint.setTypeface(Iconify.getTypeface(context));
        paint.setStyle(Paint.Style.STROKE);
        paint.setTextAlign(Paint.Align.CENTER);
        paint.setUnderlineText(false);
        paint.setColor(Color.BLACK);
        paint.setAntiAlias(true);
    } 
 
    /** 
     * Set the size of this icon to the standard Android ActionBar. 
     * @return The current IconDrawable for chaining. 
     */ 
    public IconDrawable actionBarSize() { 
        return sizeDp(ANDROID_ACTIONBAR_ICON_SIZE_DP);
8
CodeRank
This code example shows how to use the following methods:setAntiAlias, setColor, setFakeBoldText, setTextAlign, setTextSize
7
CodeRank
This code example shows how to use the following methods:getFontMetricsInt, measureText, setColor, setTextAlign, setTextSize

Related Paint setTextAlign Questions & Answers:

setTextAlign Method Overview
Set the paint's text alignment.
See Code Examples for other Android Paint Methods: