【问题标题】:ConstraintLayout does NOT support weight 1:6:1 in verticalConstraintLayout 不支持垂直方向的权重 1:6:1
【发布时间】:2018-02-02 13:30:54
【问题描述】:
<?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

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

【问题讨论】:

    标签: android android-layout android-constraintlayout constraint-layout-chains


    【解决方案1】:

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

    更改您的 build.gradle 文件以使用版本 1.1.0:

    compile 'com.android.support.constraint:constraint-layout:1.1.0-beta4'
    

    【讨论】:

      猜你喜欢
      • 2018-02-16
      • 2017-09-03
      • 2019-01-15
      • 2013-05-04
      • 2021-09-24
      • 2019-08-01
      • 2023-03-22
      • 1970-01-01
      • 2018-03-02
      相关资源
      最近更新 更多