Sai
Sai

Reputation: 15738

New line in databinding android

How can I use newline \n in data binding? I tried below but it is not working as intended. Any help thanks in advance.

android:text="@{data.firstName + `\n` + data.lastName}"

Upvotes: 1

Views: 1279

Answers (1)

Ravi
Ravi

Reputation: 35569

\n will work perfectly, but there are some cases where it will not work, just make sure you have not used that.

singleLine

If you have used android:singleLine="true" then it will not work, it won't show text in next line.

maxLines

If you have used android:maxLines="1", then it will not work, it won't show text in next line.

Upvotes: 2

Related Questions