I want to put more than one paragraph in my android xml, how?

3

I want to do something very simple. I want when the user press the "msg" button a message appears with at least two short paragraphs just below the button, but I'm finding it difficult to put the information inside a TextView because it does not let me format the text the way I want and when I put all text inside the TextView the paragraph gets all broken. Can someone help me?

xml:

 <LinerLayout
 android:layout_width = "match_parent"
 android:layout_height = "wrap_content"
 android:background = "#ddd"
 android:orientation = "vertical">

<Button
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:text ="aperte!"
 android:onclick = "imprimirTexto"/>

 <TextView
  android:id = "@+id/textoTextView"
  android:layout_width ="wrap_content"
  android:layout_height = "wrap content"
  android:layout_gravity = "center"/>

 </LinearLayout>

java

public class MainActivity extends Activity{
 private TextView texto;
 public void onCreate(Budle saveInstanceState){
   super.onCreate(saveInstanceState);
   setContentView(R.layout.main);

  texto = (TextView) findViewById(R.id.textoTextView);

}
public void imprimirTexto(View v){
  texto.setText("meus paragrafos ficam aqui");
 }
 }
    
asked by anonymous 03.12.2015 / 21:47

1 answer

0

You have two possibilities:

  • Add another TextView to the layout and split the text by the two.
  • Put a value in dp (eg 100dp ) or match_parent in android:layout_width . In the case of the value in dp the necessary lines are created, with the indicated length, in order to present the whole text. If you use match_parent , the required lines are created, with the length of layout , to display the entire text.
03.12.2015 / 23:08