我正在创建一个简单的回收站视图项布局,在约束布局中包含图像和textview . 我将图像的约束设置在左侧,文本从图像的右侧开始,到父级的末尾 . 但是,当我这样做时,屏幕上不会显示文本视图 . 有人可以帮助我 . 提前致谢 .
<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中删除应用程序:layout_constraintEnd_toEndOf = "parent",我得到以下结果 .
2 回答
尝试删除
来自textView元素的属性
布局代码:
我建议你在使用_63395时为每个视图连接两个轴中的至少一个点,即你应该垂直连接至少一个点,水平连接一个点以使其正确 . 另外,如果您阅读了有关如何正确使用
ConstraintLayout
的信息,它也会说明相同的内容 . 我相信这可以解决您的问题(您还可以在实际设备上看到您的所有观点) .Do something like this:
Screenshot (of the above code):
屏幕尺寸 - 7.0英寸(1200 x 1920像素)[设备:Nexus 7]
欲了解更多信息,请访问:https://codelabs.developers.google.com/codelabs/constraint-layout/index.html#7
我希望这可以帮助你 .