[android] Android TextView padding between lines

I have a TextView which displays a long text. I want to give some space between lines like in CSS with line-height property. How can I do it?

This question is related to android textview

The answer is


you can look into android:lineSpacingExtra and apply it to your XML

Additional Info is on this page

or the related method public void setLineSpacing (float add, float mult)

Additional Info here


Adding android:lineSpacingMultiplier="0.8" can make the line spacing to 80%.


If you want padding between text try LineSpacingExtra="10dp"

<TextView
        android:layout_width="match_parent"
        android:layout_height="180dp"
        android:lineSpacingExtra="10dp"/>

This supplemental answer shows the effect of changing the line spacing.

enter image description here

You can set the multiplier and/or extra spacing with

textView.setLineSpacing(float add, float mult)

Or you can get the values with

int lineHeight = textView.getLineHeight();
float add = tvSampleText.getLineSpacingExtra();          // API 16+
float mult = tvSampleText.getLineSpacingMultiplier();    // API 16+

where the formula is

lineHeight = fontMetricsLineHeight * mult + add

The default multiplier is 1 and the default extra spacing is 0.


You can use TextView.setLineSpacing(n,m) function.