7

I have implemented 3 Chip within a ChipGroup in my application successfully, but I am having trouble making an icon at the left appear.

<android.support.design.chip.ChipGroup
    android:id="@+id/chip_group"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal"
    android:layout_marginTop="32dp"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/img_announcement_photo"
    app:singleLine="true"
    app:singleSelection="true">

    <android.support.design.chip.Chip
        android:id="@+id/chip_donate"
        style="@style/ChipStyle"
        android:checked="true"
        app:chipIcon="@drawable/ic_donate_black_24dp" />

    <android.support.design.chip.Chip
        android:id="@+id/chip_sell"
        style="@style/ChipStyle"
        app:chipIcon="@drawable/ic_sell_black_24dp" />

    <android.support.design.chip.Chip
        android:id="@+id/chip_trade"
        style="@style/ChipStyle"
        app:chipIcon="@drawable/ic_trade_black_24dp" />
</android.support.design.chip.ChipGroup>

But it doesn't show. I've tried programmatically as well, but no success. I am not yet using the new namespace, but the old com.android.support:design:28.0.0-alpha3 because I am also using Google Maps, and it is not yet supported by androidx.*.

3 Answers3

15

Try adding app:chipIconVisible="true" to your chip style .

el2e10
  • 1,518
  • 22
  • 22
10

Actually since app:chipIconEnabled is deprecated it has to be app:chipIconVisible="true" now.

blebleble
  • 424
  • 6
  • 13
4

If your style @style/ChipStyle contains style="@style/Widget.MaterialComponents.Chip.Choice" or style="@style/Widget.MaterialComponents.Chip.Filter", the icon will not show. I don't know what Google's reasoning is for this but I think is pretty silly.

Aden Diamond
  • 301
  • 4
  • 23