0

I'm trying to create something that Looks like this:

A.
I. Point 1
II. Point 2
III. Point 3
1.) Subpoint 1
2.) Subpoint 2

IV. Point 4
B.
I. Point 1
II. Point 2
III. Point 3
C.
I. Point 1
1.) Subpoint 1
2.) Subpoint 2

Only that points are indented and sub points indented twice. I tried to achieve this by using \t in Java which works almost perfectly except when the text is too long and it moves to the next line. Other users tried to solve this using SpannableString and LeadingMarginSpan but they only seem to work for one indentation not two or more. Oh and it also has to be DYNAMIC meaning the number of points and sub points as well as their length can differ.

1 Answers1

0

How about Using different margin/paddings on the textviews?

    <TextView
        android:id="@+id/point1A"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="10dp"
        android:text="Point 1 A"/>

    <TextView
        android:id="@+id/point2A"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="10dp"
        android:text="Point 2 A"/>

     <TextView
        android:id="@+id/point3A"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="10dp"
        android:text="Point 3 A"/>

    <TextView
        android:id="@+id/subpoint1A"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="20dp"
        android:text="Subpoint 1 A"/>

    <TextView
        android:id="@+id/subpoint2A"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="20dp"
        android:text="Subpoint 2 A"/>

    <TextView
        android:id="@+id/point1B"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="10dp"
        android:text="Point 1 B"/>

    <TextView
        android:id="@+id/point2B"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="10dp"
        android:text="Point 2 B"/>

     <TextView
        android:id="@+id/point3B"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="10dp"
        android:text="Point 3 B"/>

     <TextView
        android:id="@+id/point1C"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="20dp"
        android:text="Point 1 C"/>

    <TextView
        android:id="@+id/subpoint1C"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="20dp"
        android:text="Subpoint 1 C"/>

    <TextView
        android:id="@+id/subpoint2C"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="20dp"
        android:text="Subpoint 2 C"/>
  • This would work for this example but as I said it needs to be dynamic. So I'm reading from a list of schemes of this format but the number of points and subpoints varies but since there are several hundred of these I can't create a new activity for each of them. Is there a way to program this dynamicly in java? So add textviews based on how many subpoints I have? – Cedric Heidrich May 14 '19 at 21:41
  • that would be a recyclerview with an adapter that recognizes different kind of items. try this: https://stackoverflow.com/questions/26245139/how-to-create-recyclerview-with-multiple-view-type and a good tutorial here: https://guides.codepath.com/android/Heterogenous-Layouts-inside-RecyclerView – Adrian Narducci May 14 '19 at 23:49