【发布时间】:2018-09-03 12:44:36
【问题描述】:
我正在尝试在约束布局中使用两个视图。但是一旦分配了边距,子视图就会出现未定义的行为。我们将不胜感激。
这是我的代码:
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:src="@drawable/ic_action_google_play"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/txtNew"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="TextHere"
android:textSize="24sp"
app:layout_constraintLeft_toRightOf="@+id/img"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
【问题讨论】:
-
您可以尝试填充 textview 而不是边距。
-
感谢 Codesalot 先生。
标签: android android-constraintlayout