Is there any way to set a choice chip as a default option? Furthermore, not to be able to uncheck any chip if there is only one chip selected?
You can use these attributes in the ChipGroup
component:
app:singleSelection="true"
. In this way the ChipGroup
can be configured to only allow a single chip to be checked at a time usingapp:checkedChip
to define a default choiceSomething like:
<com.google.android.material.chip.ChipGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:singleSelection="true"
app:checkedChip="@id/ch2">
<com.google.android.material.chip.Chip
style="@style/Widget.MaterialComponents.Chip.Choice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ch1"
android:text="M"/>
<com.google.android.material.chip.Chip
style="@style/Widget.MaterialComponents.Chip.Choice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ch2"
android:text="F"/>
</com.google.android.material.chip.ChipGroup>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With