首页 > 解决方案 > 如何在 flexbox 中居中“TextView”?

问题描述

我尝试在 FlexboxLayout 中将文本居中。我使用这个库 com.google.android:flexbox:0.2.5。我在列中有几个文本。我尝试了很多方法将它们放在该列的中间但没有成功。

<com.google.android.flexbox.FlexboxLayout
            xmlns:app="http://schemas.android.com/apk/res-auto"
            style="?metaButtonBarStyle"
            android:layout_width="77dp"
            android:layout_height="match_parent"
            android:background="@drawable/bg_pattern_dark_bitmap"
            android:orientation="vertical"
            android:alpha="1"
            app:flexWrap="wrap"
            app:justifyContent="space_between"
            >

        <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="lol"
                />
        <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="lol"
                />
        <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="lol"
                />
    </com.google.android.flexbox.FlexboxLayout>

感谢您的任何帮助

标签: androidxmlandroid-flexboxlayout

解决方案


使用app:justifyContent="space_evenly"代替space_between


推荐阅读