h6ah4i/android-advancedrecyclerview

recyclerView shrinks when using "targetSdkVersion >22" but works fine when using "targetSdkVersion 22"

Open

#394 opened on Jun 5, 2017

View on GitHub
 (5 comments) (0 reactions) (1 assignee)Java (5,296 stars) (879 forks)batch import
help wantedquestion

Description

In the advancedrecyclerview sample app, the recyclerView shrinks if any view above the recyclerView renders after the recyclerView is rendered

Setup: targetSdkVersion 23 or 24 or 25

changes in fragment_recycler_list_view.xml as

<?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"
    android:fillViewport="true"
    android:overScrollMode="never"
    android:scrollbars="none">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:animateLayoutChanges="true"
        android:clipChildren="false"
        android:gravity="center_horizontal"
        android:orientation="vertical"
        android:overScrollMode="never">

        <View
            android:id="@+id/view_dummy"
            android:layout_width="match_parent"
            android:layout_height="300dp"
            android:background="@color/bg_swipe_group_item_pinned"
            android:visibility="gone" />

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recycler_view"
            style="@style/myRecyclerViewStyle"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </LinearLayout>
</ScrollView>

changes in ExpandableDraggableSwipeableExampleFragment.java as

        final View dummyView = getView().findViewById(R.id.view_dummy);
        mRecyclerViewExpandableItemManager.setDefaultGroupsExpandedState(true);
        mRecyclerView.setNestedScrollingEnabled(false);
        mRecyclerView.postDelayed(new Runnable() {
            @Override
            public void run() {
                dummyView.setVisibility(View.VISIBLE);
            }
        }, 2000);

after initializing the RecyclerViewExpandableItemManager.

But the same setup works fine with targetSdkVersion 22

Contributor guide