【发布时间】:2019-05-10 05:25:10
【问题描述】:
我正在创建一个简单的回收器视图项布局,其中包含约束布局内的图像和文本视图。我将图像的约束设置在左侧,文本从图像的右侧开始到父级的末尾。但是,当我这样做时,屏幕上不会显示文本视图。有人可以帮帮我吗。提前致谢。
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tv_character_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="2"
android:minHeight="100dp"
android:paddingBottom="20dp"
android:paddingEnd="10dp"
android:paddingStart="10dp"
android:paddingTop="20dp"
android:textSize="24sp"
android:textStyle="bold"
tools:text="Homer"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/img_character_photo"/>
<ImageView
android:id="@+id/img_character_photo"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@color/colorAccent"
android:padding="5dp"
app:layout_constraintStart_toStartOf="parent"
/>
</android.support.constraint.ConstraintLayout>
</layout>
如果我从 textView 中删除 app:layout_constraintEnd_toEndOf="parent" ,我会得到以下结果。
【问题讨论】:
-
请检查文本颜色 - 我猜它是白色的(您的布局在我的示例应用程序中看起来不错)。 BTW LayoutInspector 是一个很好的工具,如果你的视图没有像他们应该的那样显示
-
@0X0nosugar 文本在我删除 app:layout_constraintEnd_toEndOf="parent" 约束时出现,但右侧的文本超出范围
标签: android android-layout layout android-constraintlayout