Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
142 views
in Technique[技术] by (71.8m points)

android - How to assign text size in sp value using java code

If I assign an integer value to change a certain text size of a TextView using java code, the value is interpreted as pixel (px).

Now does anyone know how to assign it in sp?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

http://developer.android.com/reference/android/widget/TextView.html#setTextSize%28int,%20float%29

Example:

textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 65);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...