我尝试在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>
谢谢您的帮助
在TextView中添加此行:
app:layout_alignSelf="center"
使用app:justifyContent="space_evenly"
代替space_between
在TextView中添加此行
android:gravity="center_vertical"