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
Post a Comment