如何使 FlexboxLayout 滚动?
How to make FlexboxLayout scroll?
我在我的一个 Activity 中使用 Android FlexboxLayout,但是当内容大于我的屏幕时,我无法滚动到那里查看它。所有示例似乎都是默认滚动,但它在我的代码中并没有这样做。
XML是这样的:
<?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>
像这样ScrollView把它包起来
<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>
我在我的一个 Activity 中使用 Android FlexboxLayout,但是当内容大于我的屏幕时,我无法滚动到那里查看它。所有示例似乎都是默认滚动,但它在我的代码中并没有这样做。
XML是这样的:
<?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>
像这样ScrollView把它包起来
<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>