views:

110

answers:

2

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.

A: 

This question has already been asked. Possible duplicate of

http://stackoverflow.com/questions/3429546/android-how-to-add-bullet-symbol-in-textview

http://stackoverflow.com/questions/2196499/ordered-lists-inside-an-android-textview

Rahul
Couldn't use html in comments so I edited orignal post, see above.
Björn
A: 

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"&gt;

    <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.

Björn