How to align ChipGroup items vertically one after the other in dynamic chips adding method

1.2k views Asked by At

enter image description here

i want to show chips as shown in the figure, but what i am getting is

enter image description here

Here is my code

<com.google.android.material.chip.ChipGroup
        android:id="@+id/chipGroup"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:chipSpacing="3dp"
        android:layout_marginTop="15dp"
        app:singleSelection="false"
        app:singleLine="false"
        app:flow_verticalAlign="center"
        android:textAlignment="center"
        android:orientation="vertical"
        app:flow_horizontalAlign="center"
        android:paddingHorizontal="10dp"
        android:gravity="center">

 @BindView(R.id.chipsSkill) ChipGroup chipGroup;

                final Chip chips = (Chip) this.getLayoutInflater().inflate(R.layout.item_chip, null, false);
      
                chips.setChipIcon(getDrawable(R.drawable.chips_bg));
                chips.setCheckable(true);
                chips.setChecked(false);
                
                if(ArraList.size()>0){
                    for(String s: ArrayList){
                        chips.setText(s.getName());
                        
                    }
                }   chipGroup.addView(chips); 
                          

How to align ChipGroup items vertically one after the other

1

There are 1 answers

1
Guhanmuthu Selvaraj On

we can align chip vertically ,by setting the chip width as match_parent android:layout_width="match_parent"

please refer to this Is it possible to set Material ChipGroup orientation to VERTICAL?