Spidey
Spidey

Reputation: 397

Create new lines between the TextView

The textview id is dynamically generated in Android. How can I put a newline or break between the TextView? Thanks.

<TextView
    android:id="@+id/rowStudentID"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="10dp" />


<TextView
    android:text="@string/new_line"
    android:id="@+id/rowStudentName"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="10dp" />

Upvotes: 1

Views: 42

Answers (2)

Yassine BELDI
Yassine BELDI

Reputation: 572

You can do this way, by creating a 1px view

   <TextView
        android:id="@+id/rowStudentID"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="10dp" />

    <View
        android:layout_width="match_parent"
        android:layout_height="1px"
        android:background="@color/divider" />

    <TextView
        android:text="@string/new_line"
        android:id="@+id/rowStudentName"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="10dp" />

Upvotes: 1

Umer Asif
Umer Asif

Reputation: 441

Here you go.Change it as you like.

     <style name="Divider">
    <item name="android:layout_width">match_parent</item>
    <item name="android:layout_height">1dp</item>
    <item name="android:background">@color/Divider</item>
    </style>

and do this.

   <TextView
android:id="@+id/rowStudentID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp" />

  <View
    style="@style/Divider"/>

   <TextView
android:text="@string/new_line"
android:id="@+id/rowStudentName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp" />

Upvotes: 1

Related Questions