如何在 flexbox 中居中 "TextView"?

How center "TextView" in flexbox?

我尝试将 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>

感谢您的帮助

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

在 TextView 中添加这一行

 android:gravity="center_vertical"

对于图像视图

将imageview放在Linearlayout中并设置gravity

  <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">

<LinearLayout android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:gravity="center_vertical">

    <ImageView
            android:layout_width="20dp"
            android:layout_height="20dp"
            android:background="@color/colorPrimary"/>

</LinearLayout>

<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="lol"
        android:gravity="center_vertical"/>

<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="lol"
        android:gravity="center_vertical"/>

</com.google.android.flexbox.FlexboxLayout>