Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Indent bullet list in TextView

I have a TextView which I fill with text from a string resources in strings.xml. The string resource contains < li > elements to create a bullet list inside the TextView. My problem is that I want to control the indention of lines in the bullet list that span over more than one line. Default the text isn't indented past the bullet so it looks kind of ugly. Is it possible to do this with style parameters or to create bullets in some other way?

Thanks in advance.

edit: Is it really answered? I don't have any problems producing the bullet list, as described in those links but I'm having problems getting the layout correct. The indentation is like this:

  • text that go beyond the width
    of the line.

And I want the "of the line" to at least start indented as far as the text after the bullet. That's what I try to achieve.

like image 977
Björn Avatar asked Sep 15 '10 08:09

Björn


People also ask

How do you do bullet points on android?

For example, a BulletSpan using the default values can be constructed like this: SpannableString string = new SpannableString("Text with\nBullet point"); string. setSpan(new BulletSpan(), 10, 22, Spanned. SPAN_EXCLUSIVE_EXCLUSIVE);

How do you insert bullet points?

Place your cursor where you want a bulleted list. Click Home> Paragraph, and then click the arrow next to Bullets. Choose a bullet style and start typing.


1 Answers

I'm suprised that there seems to be noone with this problem. I mean, bullet list can't be that uncommon in about-dialogs, FAQ etc and a bullet doesn't have to contain too much text to span more than one row and run into this problem.

Anyway, I got to solve it like this for now:

<?xml version="1.0" encoding="utf-8"?> <ScrollView     android:id="@+id/ScrollViewTipsLayout"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     xmlns:android="http://schemas.android.com/apk/res/android">      <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"          android:id="@+id/TipsLayout"         android:layout_width="fill_parent"          android:layout_height="wrap_content">          <TableLayout         android:layout_height="wrap_content"         android:id="@+id/TableLayout01"         android:layout_width="wrap_content"     >         <TableRow>             <TextView android:id="@+id/tvIngress"                 android:layout_height="wrap_content"                  android:layout_width="wrap_content"                  android:text="@+string/tv_picking_content_ingress"                 android:layout_span="2"                 android:singleLine="false"                 android:layout_weight="1"             />         </TableRow>         <TableRow>             <TextView android:id="@+id/tvCleaningDot1"                 android:layout_height="wrap_content"                  android:text="•"                 android:singleLine="false"             />             <TextView android:id="@+id/tvCleaningFirst"                 android:layout_height="wrap_content"                  android:text="@+string/tv_picking_content_first"                  android:layout_width="0dp"                 android:layout_weight="1"                 android:gravity="left"                 android:singleLine="false"              />         </TableRow>             <TextView android:id="@+id/tvCleaningDot2"                 android:layout_height="wrap_content"                  android:text="•"                 android:singleLine="false"             />             <TextView android:id="@+id/tvCleaningSecond"                 android:layout_height="wrap_content"                  android:text="@+string/tv_picking_content_second"                  android:layout_width="0dp"                 android:layout_weight="1"                 android:gravity="left"                 android:singleLine="false"             />         </TableRow>     </TableLayout> </RelativeLayout> 

I use it to present static text in a bullet list so I don't bother to create the bullet + text dynamically in code. If anyone have any suggestion how to accomplish the same thing in a better way, please enlight me.

Btw, if going with the solution suggested in second link above:

android:text="<ol><li>item 1\n</li><li>item 2\n</li></ol> 

The second, third etc. row in a bullet that span over more than one row won't get same indention as first line, which is quite ugly.

like image 105
Björn Avatar answered Oct 06 '22 13:10

Björn