Reputation: 3265
I tested my code in API 24, 26, 27 and 28 and it worked like a charm (Top to Bottom and Left to Right) but when I tested it in API 16 I found out that GridLayoutManager
is filling items from Bottom to Top and from Right to Left. I guess this problem occurs in API<17
This is My Code:
RecyclerView recyclerView = v.findViewById(R.id.recyclerview);
recyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 2));
recyclerView.setAdapter(mAdapter);
How can I fix it in API 16?
It is important to know this problem doesn't occur for All Devices < API 17 . because I tested app in Samsung Galaxy S3 (API 16) and it didn't reverse the list.
Upvotes: 2
Views: 591
Reputation: 3265
I decided to reverse my ArrayList when the API level of an Android device is lower than 17 (4.2 or JELLY_BEAN_MR1).
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
Collections.reverse(mlist);
}
and then it is obvious that I should set mList to recyclerAdapter.
Upvotes: 1