I have an item ( TextField, or TextArea, ...). It has a content value , say "hello world". How to know the number of pixels that this "hello world" String value is occupying on the screen ?
Asked
Active
Viewed 87 times
1 Answers
2
You can get the preferred width/height to get a rough estimation (you would also need to add the margin's to get accurate sizing). However the layout manager views these as guidelines not as final sizes and can decide on placing a component anywhere.
During runtime e.g. paint etc. the getX/Y/Width/Height argument provide accurate component size and position. However, these are only valid for the current paint operation since a device may be rotated or might require layout reflow.
You need to be more specific on what you are trying to accomplish.

Shai Almog
- 51,749
- 5
- 35
- 65