I use ChipGroup in fragment to put entries I picked up from the list
<com.google.android.material.chip.ChipGroup
android:id="@+id/cgGroup"
android:layout_width="match_parent"
android:layout_height="@dimen/bounds_xxl"
android:layout_gravity="center"
android:layout_marginStart="@dimen/bounds_l"
android:layout_marginTop="@dimen/bounds_l"
android:layout_marginEnd="@dimen/bounds_l"
android:background="@drawable/item_grey_box"
android:drawableEnd="@drawable/ic_pick_icon"
android:focusable="false"
android:paddingEnd="@dimen/bounds_m"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvLabelGroup"
bind:bindFilterViewModel="@{viewModelFilter}"
bind:onClick="@{fragmentFilter}"
tools:ignore="RtlSymmetry" />
Since my ChipGroup height is going to be fixed size, if I add more Chip views to ChipGroup than it can fit, then only first few will be shown and the rest will remain hidden. So I want to get number of those hidden chips in order to show some "+5 more" text label under the ChipGroup. I tried:
var invisibleElements = 0
chipGroup.forEach { chip ->
if (!(chip as Chip).isVisible) {
invisibleElements++
}
}
but then I realized I never actually set that chips to invisible. In fact they are set to View.VISIBLE by default but it is the ChipGroup that could not show them all.
I don't want to set my ChipGroup scrollable or something like that, i just want some kind of chipGroup.hiddenChildCount method