0
<?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"
    android:padding="10dp"
    tools:backgroundTint="#ff00ffff">

    <View
        android:id="@+id/spc_core_t"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:background="#ff00ff00"
        app:layout_constraintBottom_toTopOf="@+id/spc_core"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_weight="1" />

    <View
        android:id="@+id/spc_core_b"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:background="#ff0000ff"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/spc_core"
        app:layout_constraintVertical_weight="1" />

    <View
        android:id="@+id/spc_core"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:background="#ffff0000"
        app:layout_constraintBottom_toTopOf="@+id/spc_core_b"
        app:layout_constraintTop_toBottomOf="@+id/spc_core_t"
        app:layout_constraintVertical_weight="6" />

</android.support.constraint.ConstraintLayout>
  1. 这是我的代码,但没有显示。
  2. 当我更改app:layout_constraintVertical_weight为其他值时,一切正常。
  3. 我尝试了其他组合,所有 1:6:1、2:12:2 等也都不起作用。
  4. 我目前的临时解决方案是将 6 更改为 6.00001

但现在我想知道为什么会这样。

4

1 回答 1

0

我不知道为什么会这样,但是当我使用 1.0.2 版的约束布局库时,我能够重现它。但是,我无法使用该库的 1.1.0 版本来重现它。

将 build.gradle 文件更改为使用 1.1.0 版:

compile 'com.android.support.constraint:constraint-layout:1.1.0-beta4'
于 2018-02-02T05:30:54.123 回答