If you have two RecyclerViews, the height is incorrect only on Android 6.0.

Asked 2 years ago, Updated 2 years ago, 80 views

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android: orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android: orientation="vertical">

            <android.support.v7.widget.RecyclerView
                android: id="@+id/recyclerView1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:focusable="false"
                app:layoutManager="LinearLayoutManager"
                tools:listitem="@layout/recyclerItem1"/>

            <android.support.v7.widget.RecyclerView
                android: id="@+id/recyclerView2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:focusable="false"
                app:layoutManager="LinearLayoutManager"
                tools:listitem="@layout/recyclerItem2"/>

        </LinearLayout>

        <!--Other Layouts...-->

    </LinearLayout>

</ScrollView>

I would like to display all items without scrolling through layout like this.
For Android 6.0 only, all items may or may not appear without scrolling.
I don't know the critical difference between what appears and what doesn't, but the same list combination always reproduces the same symptom every time.

Since I use two RecyclerViews, I think there may be problems with calculating the height and the order of calculating the parent's layout. Do you have any ideas about where I can solve this problem?
Thank you for your cooperation.

Android Studio: 2.2.2 Library version: com.android.support:recyclingview-v7:25.0.1

android android-layout

2022-09-30 10:55

1 Answers

Even if I set the height of RecyclerView to wrap_content myself, there was a phenomenon in which there was not enough space for all child views.
When I changed ScrollView to Android.support.v4.widget.NestedScrollView, it worked as expected.


2022-09-30 10:55

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.