提问者:小点点

为什么不工作重心复选框


我有一个复选框并设置重心,但这个框不在中心

这是我的XML文件

<CheckBox
    android:id="@+id/checkBox"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginStart="32dp"
    android:layout_marginTop="8dp"
    android:gravity="center"
    android:checked="false"
    android:clickable="false"
    app:buttonTint="@color/colorPrimary"
    android:scaleX="1.4"
    android:scaleY="1.4"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

在此处复选图像


共2个答案

匿名用户

ConstraintLayout Chains Android开发人员最近发布了ConstraintLayout的新版本(截至今天为1.0.2)。 这个版本包含了一个新的主要特性--Chains,它允许我们在ConstraintLayout中对视图进行分组。

链在单个轴(水平或垂直)上提供类似群的行为。

如果一组小部件通过双向连接链接在一起,则将它们视为链

一旦创建了链,就有两种可能性:

在可用的空间中分散元素链也可以“打包”,在这种情况下,元素被组合在一起

匿名用户

也许我弄错了,但是我用单选按钮做了同样的尝试,它只将与单选按钮相关联的文本居中。 但我想您可以在这里找到您的答案:https://stackoverflow.com/questions/47386980/align-checkbox-to-center-of-the-listview-item/47387075#:~:text=create%20a%20linearLayou%20as%20parent.&text=如果%20you%20check%20the%20device,它%20应该%20工作。