安卓芯片材料组件上下方出现了额外的空间。

15

我在布局中使用了Chip视图
自从将材料设计组件从1.0.0升级到1.1.0以后,视图的顶部底部出现了额外的空间
我找不到任何关于如何去除这些空间的文档

在材料1.0.0中

enter image description here

在材料1.1.0中

enter image description here

<com.google.android.material.chip.Chip
    style="@style/Widget.MaterialComponents.Chip.Action"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintBottom_toBottomOf="parent"
    android:text="Groceries"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"/>

1
你能否将你的代码作为文本添加,而不是图片? - Md. Asaduzzaman
1个回答

38

这与chipMinTouchTargetSize属性有关。
你可以在Chip源代码中找到:

if (shouldEnsureMinTouchTargetSize()) {
  setMinHeight(minTouchTargetSize);
}

您可以在布局或样式中更改chipMinTouchTargetSize:

    <com.google.android.material.chip.Chip
        app:chipMinTouchTargetSize="32dp"
        ../>

或者您可以设置app:ensureMinTouchTargetSize="false"

enter image description here

注意更改此值,因为它会改变最小触摸目标的大小。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接