我想知道在Android中是否有一种方法可以使用
例如,我如何通过以下布局xml实现这一点(最大间距= 20dp)?
ConstraintLayout
,在使用Chains
时设置两个视图之间的最大间距。我知道使用margin
属性可以像两个视图之间的最小间距一样工作,但我无法找到如何设置最大间距。例如,我如何通过以下布局xml实现这一点(最大间距= 20dp)?
<?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="match_parent">
<View
android:id="@+id/left_view"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="#FF0000"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/right_view"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintHorizontal_chainStyle="spread" />
<View
android:id="@+id/right_view"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="#00FF00"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@+id/left_view"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>