This Example Work Correctly for conver text to image left align (TextPaint.Align.LEFT) but when in change it to TextPaint.Align.RIGHT converted image was empty.
Convert text to image file on Android
this is my code:
final TextPaint textPaint = new TextPaint()
{
{
setColor(Color.rgb(0, 0, 0));
setTextAlign(TextPaint.Align.RIGHT);
setTextSize(textSize);
setTypeface(NormalFont(getApplicationContext()));
setAntiAlias(true);
}
};
final Rect bounds = new Rect();
textPaint.getTextBounds(text, 0, text.length(), bounds);
final Bitmap bmp = Bitmap.createBitmap(bounds.width(), bounds.height()+buttonPadding, Bitmap.Config.ARGB_8888); //use ARGB_8888 for better quality //RGB_565
final Canvas canvas = new Canvas(bmp);
canvas.drawText(text, 0, textSize, textPaint);
return bmp;
}