【发布时间】:2021-12-24 14:36:07
【问题描述】:
我的recyclerview 有以下cardview 布局,其中有3 个视图,即ImageView、TextView 和TextView,如下所示
我面临一个奇怪的问题,即使在有适当的约束之后,它仍然会相互重叠两个 TextView。
问题。 :状态(TextView)在最右边。还有,名字 (TextView) 在最左侧的图像之后开始。如果是文本数据 很长,则名称与状态文本重叠。
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/cv_background"
app:cardCornerRadius="@dimen/rad_base"
app:contentPadding="@dimen/s_base">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/left_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_margin="@dimen/s_base"
android:src="@drawable/ic_menu"/>
<TextView
style="@style/headline_6"
android:id="@+id/status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="LIVE"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginRight="@dimen/s_base"
android:layout_marginTop="@dimen/s_base"
android:gravity="center_vertical"
android:textColor="@color/succ"/>
<TextView
style="@style/headline_6"
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/col_gray"
app:layout_constraintStart_toEndOf="@+id/left_image"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintRight_toLeftOf="@+id/status"
android:layout_marginLeft="@dimen/spacer_s"
android:layout_marginTop="@dimen/s_base"
android:text="Dummy Dummy Dummy Dummy Dummy Dummy"
android:gravity="center_vertical"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
【问题讨论】:
标签: android android-layout constraints android-constraintlayout android-cardview