Reputation: 5174
I have a TextView
whit custom TextAppearance
that changes space between lines:
<style name="CustomAppearance">
<item name="android:lineSpacingExtra">30sp</item>
</style>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Lorem ipsum lorem ipsum lorem ipsum lorem ipsum..."
android:textAppearance="@style/CustomAppearance" />
The problem is that lineSpacingExtra
value is ignored when the app launches. (Though it works if I use CustomAppearance
through style
instead of textAppearance
attribute)
Upvotes: 2
Views: 1309
Reputation: 5174
It doesn't work because lineSpacingExtra
isn't supported inside TextAppearance:
Some common TextView attributes not included are lineHeight[Multiplier|Extra], lines, breakStrategy & hyphenationFrequency. TextAppearance works at the character level, not paragraph so attributes affecting the whole layout are not supported. TextView styling by Nick Butcher
The solution for me was to use MaterialTextView along with lineHeight
attribute:
<com.google.android.material.textview.MaterialTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Lorem ipsum lorem ipsum lorem ipsum lorem ipsum..."
android:textAppearance="@style/CustomAppearance" />
<style name="CustomAppearance">
<item name="lineHeight">30sp</item>
</style>
Upvotes: 7