1

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>
Bart Friederichs
  • 33,050
  • 15
  • 95
  • 195
  • check this https://stackoverflow.com/a/50411183/7666442 and https://stackoverflow.com/questions/49973244/android-gridlayout-with-dynamic-number-of-columns-per-row/49973416#49973416 – AskNilesh Mar 08 '19 at 12:48

1 Answers1

4

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>
Vinil Prabhu
  • 1,279
  • 1
  • 10
  • 22