我在android中使用ConstraintLayout布局。我希望我的图像在左侧,我的文本在我的图像右侧。
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/galleryImg"
android:layout_width="150dp"
android:layout_height="150dp"
android:onClick="toggleMode"
android:layout_marginLeft="10dp"
android:scaleType="centerCrop"
android:src="@drawable/slider"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="parent"
/>
<TextView
android:id="@+id/galTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="Quick Brown Fox Jumps Over Quick Brown Fox Jumps Over"
android:textSize="18sp"
android:layout_alignParentRight="true"
app:layout_constraintStart_toEndOf="@+id/galleryImg"
app:layout_constraintTop_toTopOf="@+id/galleryImg" />
</android.support.constraint.ConstraintLayout>
但我的文字正在切断右侧 - 如果我的文字在第一行结束结束..它只显示 ov 并且下一行以快速
答案 0 :(得分:4)
在这里,这应该有效:
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/galleryImg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:contentDescription="TODO"
android:src="@drawable/slider"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<TextView
android:id="@+id/galTitle"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:text="Quick Brown Fox Jumps Over Quick Brown Fox Jumps Over"
app:layout_constraintBottom_toBottomOf="@+id/galleryImg"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/galleryImg"
app:layout_constraintTop_toTopOf="@+id/galleryImg"/>
</android.support.constraint.ConstraintLayout>