【问题标题】:How to align ChipGroup items vertically one after the other in dynamic chips adding method如何在动态芯片添加方法中一个接一个地垂直对齐芯片组项目
【发布时间】:2020-11-23 10:11:15
【问题描述】:

我想显示如图所示的筹码,但我得到的是

这是我的代码

<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); 
                          

如何将 ChipGroup 项目一个接一个地垂直对齐

【问题讨论】:

    标签: android material-design android-xml android-chips


    【解决方案1】:

    我们可以垂直对齐芯片,通过将芯片宽度设置为match_parent android:layout_width="match_parent"

    请参考这个Is it possible to set Material ChipGroup orientation to VERTICAL?

    【讨论】:

    • 感谢您的回答,但由于我正在动态设置芯片,因此无法正常工作。
    猜你喜欢
    • 2020-09-02
    • 2019-06-22
    • 2018-12-14
    • 1970-01-01
    • 1970-01-01
    • 2020-11-01
    • 2019-12-22
    • 2020-08-25
    • 2019-09-11
    相关资源
    最近更新 更多