Android: how to give bulletpoints, line break to text in textview
Solution 1
Thank you all...i finally ended up doing this
String nodata="hi how are you<br/>•welcome to stackoverflow"
TextView nodata= ((TextView) findViewById(R.id.nodata));
nodata.setText(Html.fromHtml(nodatafound));
and for justify left i did change in my layout file android:layout_gravity=center|left
i hope there is a betterway doing this.
Solution 2
place this code in strings.xml
hi how are you \n
• welcome to stackoverflow
set this text to your textview
Solution 3
If you wanna do it in java (I means dynamically) use \n
for line break and Unicode character for bullet i.e. \u25CF
.
This is How I'm using it
textView.setText("Welcome Username\n\u25CF Some Instructions");
It looks as
Welcome Username
● Some Instructions
Your case should be something like
textView.setText("hi how are you\n\u25CF welcome to stackoverflow");
Here are some code
• = \u2022
● = \u25CF
○ = \u25CB
▪ = \u25AA
■ = \u25A0
□ = \u25A1
► = \u25BA
Solution 4
You forgot the colon after •
So change it to this:
String nodata="hi how are you<br/>•welcome to stackoverflow"
TextView nodata= ((TextView) findViewById(R.id.nodata));
nodata.setText(Html.fromHtml(nodatafound));
teekib
Updated on June 30, 2022Comments
-
teekib almost 2 years
i have a textview with large text in it, but i want to give bulletpoints, line breaks , i tried placing xml entities like
•
for bullet point in mystring.xml
, but unable to get linebreak and few text comes in the middle, i like to use justify tooString nodata="hi how are you<br/>•welcome to stackoverflow" TextView nodata= ((TextView) findViewById(R.id.nodata)); nodata.setText(Html.fromHtml(nodatafound));
it kind of works but I am unable to use justify , is there any way I can achieve this?
-
teekib over 11 yearsi am sorry ..actually the question is without this quote marks ""..i edited
-
User over 11 years<string name="text">hi how are you \n •  welcome to stackoverflow \n </string> and set text to your textview in your xml file android:text="@string/text"
-
teekib over 11 yearswhat is this " " entity for ? some text is cooming in the middle how to justify to rightside?