本文介绍了Android如何将芯片组中的芯片居中对齐?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在XML文件中为ChipGroup尝试了gravity="center"foregroundGravity="center"textAlignment="center",但是它不起作用.有任何想法吗?

I tried gravity="center" , foregroundGravity="center" and textAlignment="center" for ChipGroup in the XML file but it won't work. Any ideas?

推荐答案

我尝试在 Flexbox 内部使用Chip a>并像这样工作.

I tried using Chip inside Flexbox and it worked like this.

<com.google.android.flexbox.FlexboxLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:orientation="horizontal"
        app:flexWrap="wrap"
        app:justifyContent="center"> ... </com.google.android.flexbox.FlexboxLayout>

应该有更好的方法来实现这一目标,但我想这将在那起作用.

There should be better ways for achieving this but this will work there I guess.

这篇关于Android如何将芯片组中的芯片居中对齐?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!