2

I use Android Studio 2.0 . I have used RecyclerView and CardView which render properly on kitkat but when the app is run on SAMSUNG A5 with android 5.1.1 (lollipop) the RecyclerView doesn't scroll and my CardView doesn't have elevation and corner.
I tried solutions suggested in SO such as adding
card_view:cardUseCompatPadding="true" and adding margin.
Even changed
xmlns:card_view="http://schemas.android.com/apk/res-auto"
to
xmlns:card_view="http://schemas.android.com/tools"
But these didn't work

This is my RecyclerView:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.RecyclerView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/grid_cards_recyclerview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clipToPadding="false"
    android:layoutDirection="rtl"
    android:padding="2dp"
    android:background="#e0e0e0"

    />

RecyclerView GridRecyclerView = (RecyclerView) getActivity().findViewById(R.id.grid_cards_recyclerview);
        GridLayoutManager gll = new GridLayoutManager(getActivity(), 2);

        GridRecyclerView.setLayoutManager(gll);
        GridAdapter gridAdapter = new GridAdapter(getActivity(), mylist);
        GridRecyclerView.setAdapter(gridAdapter);

this is a strange behavior: if I move up my finger on screen (scroll down), recyclerview doesn't show any change but if I go to another activity and come back I see the recyclerview has scrolled down!! How do you explain this behavior?! Recyclerview recognizes scroll motion but doesn't show its reaction and doesn't update its view!

Mneckoee
  • 2,802
  • 6
  • 23
  • 34
  • I think the problem may be because the recyclerview is covering the entire layout. Put the recyclerview inside a linearlayout/ relativelayout. I think the recyclerview may be confused with the match_parent height width. Try to make it wrap_content or provide some value in dp – suku May 15 '16 at 13:03
  • I put the recyclerView with height="wrap_content" in a linearLayout with height="match_parent" but not work again. – Mneckoee May 15 '16 at 13:31

2 Answers2

0

Make sure you're using com.android.support:recyclerview-v7:22.2.0

(With version prior to 22.2.0 it didn't work for me either)

Shridutt Kothari
  • 7,326
  • 3
  • 41
  • 61
0

I solved RecyclerView issue. I searched a lot. I write my code in a fragment and for previewing them I used

fragmentTransaction.add(R.id.fragment_main,
                fragment);

so in lollipop my fragment went behind the previous fragment and didn't handle touches so now I use

fragmentTransaction.replace(R.id.fragment_main,
                    fragment);

Now recyclerView is scrolling.

For shadow I used card_view:cardUseCompatPadding="true" but didn't work because I set android:hardwareAccelerated in Manifest to false. Making it true solved the problem.

Community
  • 1
  • 1
Mneckoee
  • 2,802
  • 6
  • 23
  • 34