How to put line break in direct xml textview?

3

I wanted to put this text more organized without having to create several textview, and I had the idea of using line break.

    
asked by anonymous 21.03.2017 / 17:44

2 answers

4

Use the escape character \n :

android:text="linha1\nlinha2\nlinha3"
    
21.03.2017 / 17:49
1

You can add HTML tags to a text of your strings.html

follows an example:

strings.html

 <string name="minha_receita_1"> <![CDATA[ <ul> <li>1 caneca ou bule</li> <li>1 garrafa térmica</li> <li>1 colher (sopa)</li> <li> 1 coador de café</li> </ul> ]]> </string>

Content html should be between <![CDATA[ ]]>

In Java, do the following:

     TextView textHtml = TextView.class.cast(convertView.findViewById(R.id.receita));
    final Spanned textoEmHtml = Html.fromHtml( getContext().getString(R.string.minha_receita_1));
    textHtml.setText(textoEmHtml);
    
21.03.2017 / 18:02