我非常新手 ConstraintLayout
,我在边距方面遇到了麻烦。 我有以下 layout
文件,但我正在尝试使 layoutNewsEventsItemImageContainer
在左侧具有 20dp
边距,同时保持 TextView
在该边距的左侧。
我做错了什么???
<?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:id="@+id/layoutNewsEventsItemContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:padding="20dp">
<TextView
android:id="@+id/lblNewsEventsItemHeadline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
app:layout_constraintRight_toLeftOf="@+id/layoutNewsEventsItemImageContainer"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<TextView
android:id="@+id/lblNewsEventsItemCopy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="TextView"
app:layout_constraintRight_toLeftOf="@+id/layoutNewsEventsItemImageContainer"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/lblNewsEventsItemHeadline"/>
<TextView
android:id="@+id/lblNewsEventsItemDateModified"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
app:layout_constraintRight_toLeftOf="@+id/layoutNewsEventsItemImageContainer"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/lblNewsEventsItemCopy"/>
<android.support.constraint.ConstraintLayout
android:id="@+id/layoutNewsEventsItemImageContainer"
android:layout_width="75dp"
android:layout_height="75dp"
android:background="@color/BackgroundColor2"
android:layout_marginStart="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent">
</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>
如您在下面的预览中所见,我的复制
TextView
被截断了。 TextView
应该保持在 layoutNewsEventsItemImageContainer
的左侧,因此换行到下一行。但是,如您所见,没有应用任何边距。