有没有办法在我按下时保持在同一个芯片上?

Is there a way to stay on the same Chip when I press it?

你好

我在 ChipGroup 中使用 Chips 并且 Chips 风格主题是 Choice

如果点击Choice Chip,芯片状态改变。 (background color,等等。)

然后你再次点击它,它会return回到原来的状态。

我想要的是当我点击同一个芯片时勾选状态不改变

但是我检查另一个Chip处于检查状态,前一个芯片的状态必须return到它的

原始状态。

是否有任何属性支持此功能?

换句话说,是否有一个 属性 可以使 checked check 保持其状态,即使它仍然是

已选中?

尝试了 java 代码但失败了。

In other words, is there a property that keeps the checked check in its state even if it is still

selected?

使用 Chip Choice 然后将芯片添加到 ChipGroup 中。

将此行添加到您的 ChipGroup

<com.google.android.material.chip.ChipGroup
app:singleSelection="true"
app:selectionRequired="true"
app:checkedChip="@id/..."
..>

然后在你的芯片中

<android.support.design.chip.Chip
android:id="@+id/chip1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checkable="true"
android:checked="true"
app:chipBackgroundColor="@color/bg_chip_state_list"
app:chipText="Test1" />

<android.support.design.chip.Chip
android:id="@+id/chip2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checkable="true"
app:chipBackgroundColor="@color/bg_chip_state_list"
app:chipText="Test2" />

关键是需要选择的ChipGroup