user703039
user703039

Reputation: 55

TextView textsize method

there are 2 methods to set the textsize of a textview. The one I am interested in setTextSize (int unit, float size). I am unable to find the int list for all the units (dp, sp,..). Anybody knows what are the int values of those units in Android? tHANKS

Upvotes: 2

Views: 1270

Answers (1)

shanet
shanet

Reputation: 7334

Via the API...

sp: TypedValue.COMPLEX_UNIT_SP

dip: TypedValue.COMPLEX_UNIT_DIP

Take a look at the constants of the TypedValue class for all the possible units.

http://developer.android.com/reference/android/util/TypedValue.html http://developer.android.com/reference/android/widget/TextView.html#setTextSize(int, float)

You can also convert to pixels dynamically: http://developer.android.com/guide/practices/screens_support.html#dips-pels

Hope that helps!

Upvotes: 3

Related Questions