此布局将显示一个具有一种颜色的视图和另一个具有另一种颜色的视图。
当 layout_constraintWidth_percent = 1 时,视图的宽度相同。当我将它设置在 0.92 <> 1 之间时,前景视图变得比背景大。
谁能解决这个问题?我需要前景是背景的 x 百分比
<?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"
android:paddingTop="15dp"
android:paddingBottom="15dp"
>
<View
android:id="@+id/background"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:background="@color/colorPrimary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
<View
android:id="@+id/foreground"
android:layout_width="0dp"
android:layout_height="80dp"
android:background="@color/colorAccent"
app:layout_constraintWidth_percent="0.94"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintBottom_toBottomOf="@id/background"
app:layout_constraintLeft_toLeftOf="@id/background"
app:layout_constraintRight_toRightOf="@id/background"
app:layout_constraintTop_toTopOf="@id/background"
/>
</android.support.constraint.ConstraintLayout>

