Updated 2 January 2018
A TextView displays text to the user and optionally allows them to edit it. A TextView is a complete text editor, however the basic class is configured to not allow editing.
In this blog you will know how to increase the spacing between two lines of TextView.
Just we need to add an attribute with your TextView that give the spacing with lines.
These are –android:lineSpacingExtra, android:lineSpacingMultiplier – use these two attributes with your TextView in XML file. or Programatically call setter method of that attribute textView.setLineSpacing().
Example-
1 2 3 4 5 6 7 8 9 10 11 |
<TextView android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="blog 1 link\blog 2 linko\nblog 3 link\nLineSpacingExtra = 10dp" android:background="#eaa3a3" android:textSize="18dp" android:layout_margin="10dp" android:padding="10dp" android:lineSpacingExtra="10dp" /> |
1 2 3 4 5 6 7 8 9 10 11 |
<TextView android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="blog 1 link\blog 2 linko\nblog 3 link\nLineSpacingExtra = 10dp" android:background="#eaa3a3" android:textSize="18dp" android:layout_margin="10dp" android:padding="10dp" android:lineSpacingMultiplier="1.2" /> |
That set for giving line spacing between lines of TextView.
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
3 comments
I want to know difference between padding and android:lineSpacingExtra.
Please guide for same.
android:lineSpacingExtra –> This will actually work well when you have a multi line text to display and will help in adjusting the spacing between the text lines.
Hope this helps you 🙂