Reputation: 202
I'm developing an app with chips.
I have a constraint layout with a TextView and a ChipGroup. The chips are added programmatically.
This is the layout
...
<com.google.android.material.chip.ChipGroup
android:id="@+id/chipGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:background="@android:color/holo_red_dark"
android:gravity="end"
app:layout_constraintBottom_toTopOf="@+id/chartView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/textView"
app:layout_constraintTop_toBottomOf="@+id/project3">
</com.google.android.material.chip.ChipGroup>
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:text="Pippo"
android:textColor="@color/greenPositive"
app:layout_constraintBottom_toTopOf="@+id/chartView"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/project3" />
...
The activity appears as the screenshot (I have put a red background in the chipgroup to show the area)
How to solve all these problems?
Upvotes: 3
Views: 3073
Reputation: 1
You can add to chipgroup in layout chip and make it invisible it will be as margin than you can add what you want programmatically
Upvotes: 0
Reputation: 359
Adding app:chipSpacingVertical
attribute to ChipGroup View will solve this.
<com.google.android.material.chip.ChipGroup
android:id="@+id/chipGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:chipSpacingVertical="4dp"/>
Upvotes: 6