How to set the textview on the right to be flush with the bottom textview enter image description here

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:id="@+id/numberCard" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="NumberCard" style="@style/TextNameTitle" android:layout_marginStart="@dimen/marginLarge" android:layout_marginTop="@dimen/marginLarge"/> <TextView android:id="@+id/nameCard" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="NameCard" style="@style/TextNameBody" android:layout_marginStart="@dimen/marginLarge" android:layout_marginBottom="@dimen/marginLarge" android:layout_below="@id/numberCard"/> <TextView android:id="@+id/totalCard" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TotalCard" style="@style/TextNameTitle" android:layout_marginEnd="@dimen/marginLarge" android:layout_marginTop="@dimen/marginLarge" android:layout_alignParentEnd="true"/> </RelativeLayout> 
  • @ Enikeyschik, rules - Anton Lyalin
  • Stick in the middle of the table (TableLayout). - Enikeyschik
  • @ Enikeyschik, with markup attributes will not work? - Anton Lyalin
  • @AntonLyalin, I don’t know in RelativeLayout. You can use it exactly in ConstraintLayout or you can use 2 LinearLayout - YuriiSPb
  • By the way, yes. You can even use horizontal linear. - Enikeyschik

2 answers 2

Register attribute:

 android:layout_alignBottom="@id/nameCard" 

Perhaps even such (if text2 is less than text1 in height):

 android:layout_height="match_parent" android:layout_alignTop="@+id/nameCard" 

And type gravity="center" and margin to align the text.

    Here is my way to solve your problem using Constraint Layout:

     <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:id="@+id/numberCard" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="8dp" android:layout_marginStart="8dp" android:layout_marginTop="8dp" android:text="NumberCard" android:textSize="24sp" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> <LinearLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginEnd="8dp" android:layout_marginLeft="8dp" android:layout_marginRight="8dp" android:layout_marginStart="8dp" android:gravity="center_vertical" android:orientation="horizontal" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/numberCard"> <TextView android:id="@+id/numberCard" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="NameCard" android:textSize="18sp" /> <TextView android:id="@+id/totalCard" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="right" android:text="TotalCard" android:textSize="24sp" /> </LinearLayout> </android.support.constraint.ConstraintLayout> 

    enter image description here

    Hope this helped :)

    PS Google recommends using Constraint Layout