Guest User

Untitled

a guest
Nov 20th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. canvas.getClipBounds(textRectangle);
  2. paint.setStyle(Paint.Style.FILL);
  3. canvas.drawRect(textRectangle,paint);
  4.  
  5.  
  6. int cHeight = textRectangle.height();
  7. int cWidth = textRectangle.width();
  8. paint.setTextAlign(Paint.Align.LEFT);
  9. paint.setColor(Color.WHITE);
  10. paint.setTextSize(getContext().getResources().getDisplayMetrics().density*14);
  11. paint.getTextBounds(previewMessage, 0, previewMessage.length(), textRectangle);
  12. float x = cWidth / 2f - textRectangle.width() / 2f - textRectangle.left;
  13. float y = cHeight / 2f + textRectangle.height() / 2f - textRectangle.bottom;
  14. canvas.drawText(previewMessage, x, y, paint);
Add Comment
Please, Sign In to add comment