How to set line spacing in a textview in android?

By | July 21, 2012

This is really simple in android. TextViews has a property called “lineSpacingExtra” which you can change to set the line spacing.

   <TextView 
           android:text="Data" 
           android:id="@+id/textview" 
           android:layout_gravity="top"
           android:gravity="left"
           android:layout_width="fill_parent" 
           android:layout_height="wrap_content"
           android:layout_centerVertical="true"
           android:layout_margin="5dp"
           android:padding="5dp"
           android:textSize="20sp"
           android:lineSpacingExtra="10dp">
          </TextView>

OR

you can call

textView.setLineSpacing()

in the java code itself.

One thought on “How to set line spacing in a textview in android?

Leave a Reply

Your email address will not be published. Required fields are marked *