У меня есть RelativeLayout и два TextView, один из которых с фоном.Выровнять базовую линию TextView и другую нижнюю часть TextView
На изображении две исходные линии выровнены, но я хочу выровнять базовую линию одного и заднего фона другого.
Вот мой XML-код.
<RelativeLayout
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="@dimen/chat_room_item_height"
android:background="?attr/selectableItemBackground"
android:paddingEnd="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingStart="16dp"
>
<!-- other stuff -->
<TextView
android:id="@+id/text_view_unread_message_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/text_view_last_message_date"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:background="@drawable/chat_unread_message_count_background"
style="@style/ChatRoomUnreadMessageCountTextStyle"
tools:text="101"
/>
<TextView
android:id="@+id/text_view_last_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/text_view_title"
android:layout_toEndOf="@id/image_view_icon"
android:layout_toLeftOf="@id/text_view_unread_message_count"
android:layout_toRightOf="@id/image_view_icon"
android:layout_toStartOf="@id/text_view_unread_message_count"
android:ellipsize="end"
android:layout_alignBaseline="@+id/text_view_unread_message_count"
android:gravity="bottom"
android:maxLines="1"
tools:text="My life is a story book with many different chapters but I don’t let everyone read it."
style="@style/ChatRoomLastMessageTextStyle"
/>
</RelativeLayout>
Я попытался обернуть TextView с фоном для различных ViewGrops, завернуть как TextView в макете, но безрезультатно.
Heyy @Erdeni Erdyneev попробовать 'андроида: layout_alignBottom = "@ + идентификатор/text_view_unread_message_count"' вместо 'андроида: layout_alignBaseline = "@ + ид/text_view_unread_message_count"' – MashukKhan
почему вы установили Android: самотеком = "снизу" в last_message , Вместо этого добавьте к нему некоторый marginBottom. – Nepster
@MashukKhan 'android: layout_alignBottom' выровнять текст в нижней строке, а не в базовой линии –