Search code examples
androidandroid-5.0-lollipopandroid-recyclerview

No scrolling for RecyclerView android Lollipop 5.x


Struggling with RecyclerVivew for Android 5.X ( Lollipop ), I have designed simple layout as:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:background="@android:color/white"
  android:orientation="vertical">
  <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="5dp"
    android:baselineAligned="false"
    android:orientation="horizontal"
    android:weightSum="4">
    <LinearLayout
      android:layout_width="0dp"
      android:layout_height="match_parent"
      android:layout_weight="1.1"
      android:gravity="center"
      android:orientation="vertical">

      <TextView
        android:id="@+id/tvAuditStartDate"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

      <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:text="@string/to" />

      <TextView
        android:id="@+id/tvAuditEndDate"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    </LinearLayout>

    <LinearLayout
      android:layout_width="0dp"
      android:layout_height="match_parent"
      android:layout_weight="1.2"
      android:gravity="center"
      android:orientation="vertical">

      <TextView
        android:id="@+id/tvAuditDepartmentName"
        style="@style/TextviewPrimaryMedium"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ellipsize="end"
        android:gravity="center"
        android:lines="1" />

      <TextView
        android:id="@+id/tvSubItem"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ellipsize="end"
        android:gravity="center" />

    </LinearLayout>

    <FrameLayout
      android:layout_width="0dp"
      android:layout_height="match_parent"
      android:layout_weight="1.2">

      <TextView
        android:id="@+id/tvAuditSubmitDate"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center" />
    </FrameLayout>

    <FrameLayout
      android:layout_width="0dp"
      android:layout_height="match_parent"
      android:layout_weight="0.5">

      <CheckBox
        android:id="@+id/chkbAuditStatus"
        android:layout_width="32dp"
        android:layout_height="32dp"
        android:layout_gravity="center"
        android:background="@drawable/check_box"
        android:button="@android:color/transparent"
        android:clickable="false"
        android:gravity="end" />
    </FrameLayout>
  </LinearLayout>
  <View
    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:background="@android:color/darker_gray" />
</LinearLayout>

And the custom RecyclerView.Adapter is attached to it, with item layout as:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:background="@android:color/white"
  android:orientation="vertical">
  <LinearLayout
      android:baselineAligned="false"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="5dp"
    android:orientation="horizontal"
    android:weightSum="4">
    <LinearLayout
      android:layout_width="0dp"
      android:layout_height="match_parent"
      android:layout_weight="1.1"
      android:gravity="center"
      android:orientation="vertical">

      <TextView
        android:id="@+id/tvAuditStartDate"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

      <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:text="@string/to" />

      <TextView
        android:id="@+id/tvAuditEndDate"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    </LinearLayout>

    <LinearLayout
      android:layout_width="0dp"
      android:layout_height="match_parent"
      android:layout_weight="1.2"
      android:gravity="center"
      android:orientation="vertical">

      <TextView
        android:id="@+id/tvAuditDepartmentName"
        style="@style/TextviewPrimaryMedium"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ellipsize="end"
        android:gravity="center"
        android:lines="1"/>

      <TextView
        android:id="@+id/tvSubItem"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ellipsize="end"
        android:gravity="center" />

    </LinearLayout>

    <FrameLayout
      android:layout_width="0dp"
      android:layout_height="match_parent"
      android:layout_weight="1.2">

      <TextView
        android:id="@+id/tvAuditSubmitDate"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center" />
    </FrameLayout>

    <FrameLayout
      android:layout_width="0dp"
      android:layout_height="match_parent"
      android:layout_weight="0.5">

      <CheckBox
        android:id="@+id/chkbAuditStatus"
        android:layout_width="32dp"
        android:layout_height="32dp"
        android:layout_gravity="center"
        android:background="@drawable/check_box"
        android:button="@android:color/transparent"
        android:clickable="false"
        android:gravity="end" />
    </FrameLayout>
  </LinearLayout>
  <View
    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:background="@android:color/darker_gray" />
</LinearLayout>

Now issue with this setup is, the setup is working fine in all the android versions except 5.X as result no scrolling to RecyclerView. Also it is not the only case where no scrolling is observer but the no scrolling is also observed in other Views like Spinner with different observation. In case of Spinners the dropdown List is shown but the selected item is not being reflected on UI. All the view are inflated within Fragment.


Solution

  • I have solved the issue by updating the support library to com.android.support:design:25.2.0. Also don't know the reason behind this and what exactly does it make difference. If any one have found any reason please let all know. It will be helpful. Thank you.