我有一个芯片组,当我点击已经选中的芯片时,它会变成未选中状态, 但是我需要始终有一个被选中的芯片。这种行为类似于单选按钮组。
<com.google.android.material.chip.ChipGroup
android:id="@+id/chip_group_filter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:checkedChip="@id/chip_1"
app:singleSelection="true">
<com.google.android.material.chip.Chip
android:id="@+id/chip_1"
style="@style/Widget.MaterialComponents.Chip.Choice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/chip1"
app:chipBackgroundColor="@color/chip_color" />
<com.google.android.material.chip.Chip
android:id="@+id/chip_2"
style="@style/Widget.MaterialComponents.Chip.Choice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/chip2"
app:chipBackgroundColor="@color/chip_color" />
</com.google.android.material.chip.ChipGroup>