0
我想让水平2视图链,所以他们都采取屏幕50%
,并使其高度相同的宽度,所以他们是正方形。目前我有这一点,这似乎并没有工作:ConstraintLayout - 水平重量为1,垂直比例
<?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">
<View
android:id="@+id/a"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#F00"
app:layout_constraintDimensionRatio="H,1:1"
app:layout_constraintEnd_toStartOf="@+id/b"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/b"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#0F0"
app:layout_constraintDimensionRatio="H,1:1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/a"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>