Skip to content

Conversation

@vyguera
Copy link

@vyguera vyguera commented Mar 6, 2023

It is possible to use layoutmanager attribute in layout xmls to use FlexboxLayoutManager as following:

<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
    app:layoutManager="com.google.android.flexbox.FlexboxLayoutManager">

The same way you can set that attribute in a style this way

<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
    android:style="@styles/MyFlexListStyle">

<resources>
    <style name="MyFlexListStyle">
        <item name="layoutManager">com.google.android.flexbox.FlexboxLayoutManager</item>
    </style>
</resources>

These PR allows you to develop a library that provides with a view/fragment/screen with a recyclerView that is styleable from the app the same way as the regular FlexboxLayout does, except for any already handled attributes (flexDirection) or unsupported ones (alignContent), so you can do the following:

<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
    android:style="@styles/MyFlexListStyle">

<resources>
    <style name="MyFlexListStyle">
        <item name="layoutManager">com.google.android.flexbox.FlexboxLayoutManager</item>
        <item name="flexWrap">wrap</item>
        <item name="justifyContent">center</item>
        <item name="alignItems">baseline</item>
        <item name="maxLine">3</item>
    </style>
</resources>

Rubén Viguera added 2 commits March 6, 2023 16:27
…FlexboxLayout does except for the already handled attributes (flexDirection) or the unsupported ones (alignContent)
@google-cla
Copy link

google-cla bot commented Mar 6, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant