Search code examples
androidandroid-layout

How to add space between two textviews


I am new to android development and I was just wondering how can I add space between two TextViews? Any help would be appreciated.

The code I have written so far

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/lbl_group_coworkers"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Coworkers" />

    <TextView 
        android:id="@id/lbl_group_"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Family"/>



</LinearLayout>

Solution

  • You can use android:layout_marginTop="value" like this

    <?xml version="1.0" encoding="utf-8"?>
        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical" >
    
            <TextView
                android:id="@+id/lbl_group_coworkers"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Coworkers" />
    
            <TextView 
                android:id="@id/lbl_group_"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="20dp"
                android:text="Family"/>
        </LinearLayout>