android textview Setting Line Spacing and Word Spacing for Fonts
- 2021-07-10 20:49:17
- OfStack
Word spacing
textView has one attribute android: textScaleX adjusts word spacing, and its value is an float type. Looking at the source code, the default textView this property is used:
android.internal.R.styleable.TextView_textScaleX
setTextScaleX(a.getFloat(attr, 1.0f));
Line spacing
Android system TextView default display of Chinese will be more compact, not very beautiful. To keep a fixed line spacing per line, you can set the properties android: lineSpacingExtra or android: lineSpacingMultiplier.
For Android TextView Chinese Wrap, see Android Custom view-Text Wrap.
1. android: lineSpacingExtra
Set the line spacing, such as "3dp".
2. android: lineSpacingMultiplier
Set a multiple of the line spacing, such as "1.2".
Reference code:
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:lineSpacingExtra="3dp"
android:lineSpacingMultiplier="1.5"
android:textStyle="bold" />