Google has published FlexboxLayout lib. Now I want use FlexboxLayout to implement a GridView effect, as the GridView has two rows and four lists. If the item count is less than 8, itemview will align left. When I use FlexboxLayout, item in second row align center, how can I put them align left?
I know little about front end.
here is the code:
<com.google.android.flexbox.FlexboxLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@android:color/holo_green_light"
android:layout_width="match_parent"
android:layout_height="300dp"
app:flexWrap="wrap"
app:alignItems="baseline"
app:alignContent="stretch"
app:justifyContent="space_around">
<android.support.v7.widget.AppCompatButton
android:background="@android:color/holo_red_dark"
android:layout_width="80dp"
android:layout_height="80dp"
app:layout_flexBasisPercent="20%"/>
<android.support.v7.widget.AppCompatButton
android:background="@android:color/holo_red_dark"
android:layout_width="80dp"
android:layout_height="80dp"
app:layout_flexBasisPercent="20%"/>
<android.support.v7.widget.AppCompatButton
android:background="@android:color/holo_red_dark"
android:layout_width="80dp"
android:layout_height="80dp"
app:layout_flexBasisPercent="20%"/>
<android.support.v7.widget.AppCompatButton
android:background="@android:color/holo_red_dark"
android:layout_width="80dp"
android:layout_height="80dp"
app:layout_flexBasisPercent="20%"/>
<android.support.v7.widget.AppCompatButton
android:background="@android:color/holo_red_dark"
android:layout_width="80dp"
android:layout_height="80dp"
app:layout_flexBasisPercent="20%"/>
<android.support.v7.widget.AppCompatButton
android:background="@android:color/holo_red_dark"
android:layout_width="80dp"
android:layout_height="80dp"
app:layout_flexBasisPercent="20%"/>
<android.support.v7.widget.AppCompatButton
android:background="@android:color/holo_red_dark"
android:layout_width="80dp"
android:layout_height="80dp"
app:layout_flexBasisPercent="20%"/>
</com.google.android.flexbox.FlexboxLayout>
Change:
app:alignItems="baseline"
app:alignContent="stretch"
app:justifyContent="space_around"
To:
app:flexWrap="wrap"
app:flexDirection="row"
app:alignItems="center"
app:alignContent="flex_start"
app:justifyContent="flex_start"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With