Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot add icon in a Chip

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.*.

like image 932
fermoga Avatar asked Jul 10 '18 15:07

fermoga


2 Answers

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

like image 141
el2e10 Avatar answered Sep 30 '22 03:09

el2e10


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

like image 25
blebleble Avatar answered Sep 30 '22 03:09

blebleble