Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- canvas.getClipBounds(textRectangle);
- paint.setStyle(Paint.Style.FILL);
- canvas.drawRect(textRectangle,paint);
- int cHeight = textRectangle.height();
- int cWidth = textRectangle.width();
- paint.setTextAlign(Paint.Align.LEFT);
- paint.setColor(Color.WHITE);
- paint.setTextSize(getContext().getResources().getDisplayMetrics().density*14);
- paint.getTextBounds(previewMessage, 0, previewMessage.length(), textRectangle);
- float x = cWidth / 2f - textRectangle.width() / 2f - textRectangle.left;
- float y = cHeight / 2f + textRectangle.height() / 2f - textRectangle.bottom;
- canvas.drawText(previewMessage, x, y, paint);
Add Comment
Please, Sign In to add comment