Android Material Chip Margin Spacing in ChipGroup

March 19, 2019

If you add multiline Chip dynamically to ChipGroup until it expand to multiple rows, there is zero margin vertical margin.

Set app:chipSpacingVertical on ChipGroup to enable margin spacing.

<com.google.android.material.chip.ChipGroup
    android:id="@+id/mainTagChipGroup"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:chipSpacingVertical="4dp"
    />

NOTE: You can set app:chipSpacingHorizontal or app:chipSpacing as well.

NOTE: Strangely, default margin for static Chip defined in xml vs dynamic Chip added programatically is different. I am using com.google.android.material:material:1.1.0-alpha04.

NOTE: Setting layoutParams on Chip doesn’t work.

This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.