目前在android中的约束布局中工作,布局在回收者视图中反复平铺。当我将文本视图限制在屏幕的左侧,边距为8 dp,然后将其与8dp的边距对比到右边的图像时,我设置宽度以包裹内容和高度,以便它只是去如果内容太大,请根据需要制作更多行。文字经过图像,有时甚至离开屏幕左边,完全忽略了约束?难道我做错了什么?约束布局设置为父宽度并将内容包装在高度中,因为它在回收器视图中反复平铺。
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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"
android:orientation="vertical"
tools:layout_editor_absoluteY="25dp"
tools:layout_editor_absoluteX="0dp">
<TextView
android:id="@+id/titleTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:layout_marginStart="122dp"
android:layout_marginEnd="121dp"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="16dp"
app:layout_constraintRight_toLeftOf="@+id/imageView"
android:layout_marginRight="8dp"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="parent" />
<TextView
android:id="@+id/descriptionTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:padding="10dp"
android:text=" asdkjasdkjfasd sdafkjdsafkjasfd fsdkjsafdkjsafd"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/imageView"
app:layout_constraintTop_toBottomOf="@+id/titleTextView"
app:layout_constraintVertical_bias="0.0"
app:layout_constraintHorizontal_bias="0.0" />
<ImageView
android:id="@+id/imageView"
android:layout_width="75dp"
android:layout_height="81dp"
app:srcCompat="@mipmap/attk_logo"
android:layout_marginEnd="8dp"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="8dp"
android:layout_marginRight="8dp"
app:layout_constraintRight_toRightOf="parent" />
</android.support.constraint.ConstraintLayout>
此处编辑器中的布局图片http://prntscr.com/es6bhs
答案 0 :(得分:0)
将此代码替换为TextView
<TextView
android:id="@+id/descriptionTextView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:padding="10dp"
android:text="asdkjasdkjfasd gdgh sd ds fj fg sj gsdfjgj jsdf gsf j sdafk jdsaf kjasfd fsd kjsaf dkjsafd"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/imageView"
app:layout_constraintTop_toBottomOf="@+id/titleTextView"
app:layout_constraintVertical_bias="0.0"
app:layout_constraintHorizontal_bias="0.484" />