When I define a TextView
in xml
, how do I add a new line to it? \n
seems not to work.
<TextView
android:id="@+id/txtTitlevalue"
android:text="Line1: \n-Line2\n-Line3"
android:layout_width="54dip"
android:layout_height="fill_parent"
android:textSize="11px" />
for the new line in TextView just add \n in middle of your text it works..
You need to put
\n
in the filestring.xml
If the TextView is in any Layout (LinearLayout for example), try to change the orientation attribute to vertical as
android:orientation="vertical"
for the layout or change theTextView
attributeandroid:singleLine="true"
to create a new line after it.I think this has something to do with your
HTM.fromHtml(subTitle)
call: a "\n" doesn't mean bupkis to HTML. Try<br/>
instead of "\n".Tried all the above, did some research of my own resulting in the following solution for rendering line feed escape chars:
Using the replace method you need to filter escaped linefeeds (e.g.
'\\\n'
)Only then each instance of line feed
'\n'
escape chars gets rendered into the actual linefeedFor this example I used a Google Apps Scripting noSQL database (ScriptDb) with JSON formated data.
Cheers :D
This works fine. Check it for your app.