android - setTextSize - sets the text bigger than expected -


i use code set text 1 sp bigger increases size much...

public void dothis(menuitem item){         size = text.gettextsize();         text.settextsize(typedvalue.complex_unit_sp, (float) (size + 1));      } 

i want add 1 sp...

thanks help

because obtain size in pixels , use translate sp. first need convert size sp:

float scaleddensity = context.getresources().getdisplaymetrics().scaleddensity; float sizenew = text.gettextsize() / scaleddensity; // obtain current size in sp sizenew += 1f; // add 1 sp text.settextsize(typedvalue.complex_unit_sp, sizenew); // set new size in sp 

Comments

Popular posts from this blog

c# - Unity IoC Lifetime per HttpRequest for UserStore -

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -