I'm using Chip view in my layout
Since upgraded material design component from 1.0.0 to 1.1.0, there is an extra space at the top and bottom of view
I couldn't find any document about how to remove these spaces
In material 1.0.0
In material 1.1.0
<com.google.android.material.chip.Chip
style="@style/Widget.MaterialComponents.Chip.Action"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:text="Groceries"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
A ChipGroup is used to hold multiple Chip s. By default, the chips are reflowed across multiple lines. Set the app:singleLine attribute to constrain the chips to a single horizontal line. If you do so, you'll usually want to wrap this ChipGroup in a HorizontalScrollView .
It is a rounded button that consists of a label, an optional chip icon, and an optional close icon. A chip can either be clicked or toggled if it is checkable. Chips may be placed in a, which can be configured to layout its chips in a single horizontal line or reflowed across multiple lines.
ChipGroup chipGroup = findViewById(R.id.....); for (int i=0; i<chipGroup. getChildCount();i++){ Chip chip = (Chip)chipGroup. getChildAt(i); if (chip. isChecked()){ //this chip is selected..... } }
It is related to the chipMinTouchTargetSize
attribute.
You can find in the Chip
source code:
if (shouldEnsureMinTouchTargetSize()) {
setMinHeight(minTouchTargetSize);
}
You can change the chipMinTouchTargetSize
in the layout or in the style:
<com.google.android.material.chip.Chip
app:chipMinTouchTargetSize="32dp"
../>
or you can set app:ensureMinTouchTargetSize="false"
.
Pay attention to change this value since it changes the minimum touch target size.
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