How to limit line height of spannablestring but keep on rest of line

Viewed 2263

I have a TextView which has a SpannableString inside it to highlight searched terms. Like so :

enter image description here

<TextView android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:id="@+id/textBox"
          android:textSize="16sp"
          android:paddingTop="10dp"
          android:paddingLeft="20dp"
          android:paddingRight="20dp"
          android:lineSpacingExtra="5dp"
          android:textColor="@color/TextGray"/>

As can be seen I am using android:lineSpacingExtra to give the lines a nice spacing, however it is causing the SpannableString background to be too tall. I would like to keep the spacing between the lines but make the SpannableString shorter.

How is this possible?

1 Answers
Related