Search code examples
androidandroid-layouttextview

How to set sizes of each line on textView Android Studio?


I know that we can use android:maxLines="" for splitting a textview into multiple rows, but I want to give size for each row (not text size, but line size). My plan is to set the textsize 18sp and line height size 25dp for each row (I use match_parent for the width). Are there any possible way to do that?


Solution

  • Two attributes (lineSpacingExtra & lineSpacingMultiplier) can be used in your xml file.

    lineSpacingExtra : add extra spacing between lines of text of TextView

    <TextView
        android:lineSpacingExtra="5dp" />
    

    lineSpacingMultiplier : scale factor for height of line space

    <TextView
        android:lineSpacingMultiplier=".6" />
    //line spacing to 60%.