Java android: appending a newline using TextView

前端 未结 5 748
离开以前
离开以前 2020-12-09 17:34

I just want to add a new line somehow to my linear layout:

layout = (LinearLayout) findViewById (R.id.layout);  

... //some other code where I\'ve appended          


        
5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-09 17:45

    First you need to make your TextView to be multiline. And then use simple "\n" string for linebreak.

    final TextView nline = new TextView(this);
    nline.setSingleLine(false);
    nline.setText("first line\n"+"second line\n"+"third line");
    

提交回复
热议问题