Android ChipDrawable 宽度没有填满他的parrent

Android ChipDrawable width not fill his parrent

我正在尝试使用 ChipGroup,它包含一些仅包含文本的 Chips。 一切正常。当有短文本时,问题就开始了。 由于某种原因,文本本身没有填满芯片,我无法解决这个问题......

我正在为 Chip 使用此布局:

<com.daytwo.core.widget.CustomChip         
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/chip"
style="@style/Chip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="64dp"/>

我的风格是:

<style name="Chip" parent="@style/Widget.MaterialComponents.Chip.Choice">
    <item name="android:textColor">@color/black</item>
    <item name="chipBackgroundColor">@color/background</item>
    <item name="rippleColor">@color/ripple</item>
    <item name="chipStrokeWidth">2dp</item>
    <item name="chipMinHeight">50dp</item>
</style>

这个Chip有一个chipMinTouchTargetSize。这会同时影响一个chip的纵横向margin,保证至少是48x48dp.

您可以在 ChipGroup.

的每个芯片中使用 app:ensureMinTouchTargetSize="false" 来禁用它