How can I get a textview to appear below another textview? Android

user2659645 picture user2659645 · Aug 12, 2013 · Viewed 28.8k times · Source

I am building a small android app and I want to display text under a textview.I can't seem to get it. At the moment the text is at the right of the list item. I want the view with the id, "list_size" to be bellow the title. Here is the code:

<RelativeLayout  xmlns:android="http://schemas.android.com/apk/res/android"
                 android:layout_width="match_parent"
                 android:layout_height="match_parent"
                 android:padding="10dp"
                 android:background="?android:attr/activatedBackgroundIndicator"
        >

    <!--suppress AndroidLintContentDescription -->
    <ImageView android:id="@+id/imageone"
               android:layout_width="@dimen/list_item_image"
               android:layout_height="@dimen/list_item_image"
               android:layout_centerVertical="true"
               android:scaleType="fitXY"/>

    <TextView android:id="@+id/title" android:layout_width="wrap_content"
              android:layout_height="wrap_content" android:fontFamily="sans-serif-light"
              android:textIsSelectable="false" android:layout_marginLeft="7dp"
              android:layout_toRightOf="@+id/imageone" android:textSize="@dimen/medium_text_size"
              android:singleLine="true" android:layout_centerVertical="true"
              android:layout_toLeftOf="@+id/divider"/>

    <View android:id="@+id/divider"
          android:layout_toLeftOf="@+id/list_size"
          android:layout_width="1dp"
          android:layout_height="10dp"/>

    <TextView android:layout_marginLeft="5dp"
              android:id="@+id/list_size" android:layout_width="wrap_content"
              android:layout_height="wrap_content" android:textSize="@dimen/small_text_size"
              android:singleLine="true" android:fontFamily="sans-serif-light"
              android:layout_alignParentRight="true"
              android:layout_centerVertical="true"/>

</RelativeLayout>

Answer

Jon picture Jon · Aug 12, 2013

You'll want to use android:layout_below

    <TextView android:layout_marginLeft="5dp"
          android:id="@+id/list_size"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:textSize="@dimen/small_text_size"
          android:singleLine="true"
          android:fontFamily="sans-serif-light"
          android:layout_alignParentRight="true"
          android:layout_below="@id/title"/>