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 some strings already
final TextView nline = new TextView(this);
nline.setText(Html.fromHtml("<br>")); //i also tried: nline.setText("\n");
layout.addView(nline);
But this just adds a few spaces. Can someone help me out? Thanks.
You may need to set the InputType to TYPE_TEXT_FLAG_MULTI_LINE using the setInputType() method of TextView
You also could just set some margin/padding on the other views. I think that TextViews should not be misused as spacers.
If you just want to have some empty space between two other views, you could do this in your XML (assuming you're using XML for the layout). Something like this could work, basically putting in a View with a transparent background and given height. This is assuming you have whatever parameters you want in your TextViews.
Also, in what you tried above... you could try a space and newline... that might work.
Simple by giving "\n" data is displayed in a new line
Simple as:
First you need to make your
TextView
to be multiline. And then use simple"\n"
string for linebreak.