【发布时间】:2020-05-09 21:46:22
【问题描述】:
我想创建一个这样的视图。
所以它与“查看全部 (35)”TextView 重叠。如何防止重叠? ImageView 应该在 TextView 的右侧,但不能与“查看全部 (35)”重叠。我想你明白了。谢谢。
这是 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="wrap_content">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:fontFamily="@font/montserrat_semi_bold"
android:maxLines="1"
android:layout_alignParentStart="true"
android:textColor="@color/colorTextDark"
android:textSize="@dimen/text_extra_large"
tools:text="Birthday" />
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginStart="8dp"
android:layout_marginEnd="16dp"
android:layout_toEndOf="@+id/textView"
android:src="@drawable/wishlist_public" />
<TextView
android:id="@+id/textViewAll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:fontFamily="@font/montserrat_semi_bold"
android:text="View all (35)"
android:layout_alignParentEnd="true"
android:textColor="@color/colorTextPrimary"
android:textSize="@dimen/text_small" />
</RelativeLayout>
【问题讨论】:
-
您有几个选择。我个人会为此使用 ConstraintLayout,但您也可以使用 LinearLayouts
-
我几乎尝试了所有方法,但没有成功
标签: java android xml layout android-relativelayout