A string as "123456" showed in the screen. I want to get the width of that string .
Display display = getWindowManager(). getDefaultDisplay(); Point size = new Point(); display. getSize(size); int width = size. x; int height = size.
TextView is the user interface which displays the text message on the screen to the user. It is based on the layout size, style, and color, etc. TextView is used to set and display the text according to our specifications.
<? xml version = "1.0" encoding = "utf-8" ?>
I dont tried, but maybe something like that:
mPaint = new Paint();
mPaint.setTextSize(64);
//...
float width = mPaint.measureText(text, 0, text.length());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With