I have TextView which contains text. It has background:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!\nEach line should be wrapped by background not whole text"
android:textColor="#000000"
android:textSize="24sp"
android:background="#FFFF00"
android:gravity="center_horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:padding="8dp"/>
Now, a background is wrapping whole text. I want it to wrap each line individually. Now I am getting the result which is shown on the left of the image. I want to achieve the result which is on the right.
I would create several TextViews with separate backgrounds but TextView shows dynamic text which makes this solution not so good.
My question: how to wrap TextView's each line with background?