How to find the Text Area(Height/Width) of TextView programmatically in android -



How to find the Text Area(Height/Width) of TextView programmatically in android -

i have edittext, button , textview. on clicking button, textview shows text written in edittext. possible find size of textview occupied depending upon text. i.e. if has 3 characters "abc", width now, if has 5 characters "abcde" , width ?

rect bounds = new rect(); paint textpaint = textview.getpaint(); textpaint.gettextbounds(text,0,text.length(),bounds); int height = bounds.height(); int width = bounds.width();

or

textview.settext("bla"); textview.measure(0, 0); textview.getmeasuredwidth(); textview.getmeasuredheight();

android android-layout android-textview layoutparams

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -