Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: how to give bulletpoints, line break to text in textview

i have a textview with large text in it, but i want to give bulletpoints, line breaks , i tried placing xml entities like &#8226 for bullet point in my string.xml, but unable to get linebreak and few text comes in the middle, i like to use justify too

String nodata="hi how are you<br/>&#8226welcome 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?

like image 596
teekib Avatar asked Feb 05 '13 12:02

teekib


People also ask

How do I add a newline to a TextView in Android?

Add Line Breaks to a TextView Just add a \n to your text. This can be done directly in your layout file, or in a string resource and will cleanly break the text in your TextView to the next line.

How do I add bullet points in TextView?

To construct a BulletSpan with a gap width of 40px, green bullet point and bullet radius of 20px: SpannableString string = new SpannableString("Text with\nBullet point"); string. setSpan(new BulletSpan(40, color, 20), 10, 22, Spanned. SPAN_EXCLUSIVE_EXCLUSIVE);

How do you strikethrough text in TextView?

If you want to show a strike-through text you can do it programming using PaintFlags. You can set paint flags Paint. STRIKE_THRU_TEXT_FLAG to a TextView and it will add a strike-through to the text. TextView textView = (TextView) findViewById(R.

How do you do bullet points on android?

The two Button s at the bottom have android:text="◄" and "►" .


1 Answers

Thank you all...i finally ended up doing this

String nodata="hi how are you<br/>&#8226;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.

like image 151
teekib Avatar answered Oct 13 '22 23:10

teekib