0

What I would like to achieve is an effect that looks like this with a TextView:

enter image description here

Basically having a background, but keeping the space between the lines. The only solution I came up with was using one TextView for each line of text, but I would prefer a cleaner one using only one multiline TextView.

Any ideas?

Alessandro Roaro
  • 4,665
  • 6
  • 29
  • 48
  • please check the following answer http://stackoverflow.com/a/8661622/957654 –  Mar 29 '15 at 14:05
  • Possible duplicate of [TextView with background color and line spacing](https://stackoverflow.com/questions/22939862/textview-with-background-color-and-line-spacing) – Evren Ozturk Jun 06 '17 at 13:15

3 Answers3

0

What you can do is use mark tag in html to textview.

myTextView.setText(Html.fromHtml("<mark>heading highlighted</mark>"));
Pang
  • 9,564
  • 146
  • 81
  • 122
Amrut
  • 543
  • 4
  • 8
0

Use spanned text for each line. Read the Spannable API.

Quark
  • 402
  • 4
  • 15
0

please refer to this answer here as it describes how to implement spacing between multiple lines in a TextView , using the following properties :

android:lineSpacingMultiplier 

android:lineSpacingExtra

Hope that Helps . Regards

Community
  • 1
  • 1