Android:TextView height doesn't change after shrinking the font size -


when click on button, font size shrinks 12. however, result :

enter image description here

main.xml

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:orientation="vertical" >      <textview         android:id="@+id/test"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:textsize="40sp"         android:background="#80ff0000"         android:text="@string/hello" />      <button         android:id="@+id/button1"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:text="button" />  </linearlayout> 

java:

public class fontsizetestactivity extends activity {     /** called when activity first created. */     @override     public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.main);         final textview text = (textview) findviewbyid(r.id.test);             button button1 = (button) findviewbyid(r.id.button1);         button1.setonclicklistener(new view.onclicklistener() {              public void onclick(view v) {                  text.settextsize(12);             }         });     } } 

how shrink height of textview wraps actual font?

so, after long search have found solution. every time set text do:

settext("i text",textview.buffertype.spannable); 

or after resizing text do:

settext(gettext(),textview.buffertype.spannable); 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -