Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make FlexboxLayout scroll?

I am using Android FlexboxLayout in one of my Activities, but when the content is larger than my screen, I cannot scroll there to see it. All examples seem to scroll be default, but it just doesn't do that in my code.

The XML is like this:

<?xml version="1.0" encoding="utf-8"?>
<com.google.android.flexbox.FlexboxLayout
    android:id="@+id/fbRoot"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:alignContent="flex_start"
    app:alignItems="stretch"
    app:flexWrap="wrap">

    .. a lot of other views ..

</com.google.android.flexbox.FlexboxLayout>
like image 880
Bart Friederichs Avatar asked Sep 10 '26 18:09

Bart Friederichs


1 Answers

Wrap it inside a ScrollView like this

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true">

    <com.google.android.flexbox.FlexboxLayout
    android:id="@+id/fbRoot"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:alignContent="flex_start"
    app:alignItems="stretch"
    app:flexWrap="wrap">

    .. a lot of other views ..

</com.google.android.flexbox.FlexboxLayout>
</ScrollView>
like image 131
Vinil Prabhu Avatar answered Sep 13 '26 07:09

Vinil Prabhu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!