Search code examples
androidlayoutmargin

How can I place near (vertically) two TextView?


Here's my Relative Layout:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="7"
    android:gravity="center"
    android:keepScreenOn="true"
    android:orientation="vertical">

    <TextView
        android:id="@+id/txtSongYear"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="0dp"
        android:ellipsize="marquee"
        android:lineHeight="40dp"
        android:padding="10dp"
        android:scrollHorizontally="true"
        android:singleLine="true"
        android:text="Year"
        android:textAlignment="center"
        android:textColor="#fff"
        android:textSize="20sp"
        android:textStyle="italic">

    </TextView>

    <TextView
        android:id="@+id/txtSongName"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="20dp"
        android:ellipsize="marquee"
        android:padding="10dp"
        android:marqueeRepeatLimit="marquee_forever"
        android:scrollHorizontally="true"
        android:singleLine="true"
        android:text="Song Name"
        android:textAlignment="center"
        android:textColor="#fff"
        android:textSize="22sp"
        android:layout_marginBottom="20dp"
        android:textStyle="italic">

    </TextView>

</LinearLayout>

which render as:

enter image description here

As you can see, the two TextView as some margin between them. I want to place near them, how can I do it?


Solution

  • remove android:padding="10dp" and android:layout_margin="20dp" can work.