ploki wrote:Thanks for the answers.
I need to know width of View (TextView). I must calculate the position of the label(because I align the words) and position is depends on labels length. Example:
mmm //3 letters but it is longer than
llllll //5 letter, so I can't calculate width from number of letters in the word, so I must have pixels-width.
I did not say "number of letters" I said "length of the text".
In fact I meant text length in pixels
As for the View (i.e. TextVeiw), it may also contain paddings and margins in all directions.
The length of text in pixels:
Using java Syntax Highlighting
FontMetrics fm = this.getFontMetrics(this.itsFont);
int width = fm.stringWidth("Test String");
Parsed in 0.010 seconds, using GeSHi
This is from here: textview_width_of_text-t382.html
Just do some search next time.