amitairos
amitairos

Reputation: 2977

RecyclerView shift items

I'm trying to make a calendar, in which the days are in a RecyclerView.
I want to show the first day of the month on the column of the day of the week it starts on.
Is there a way to shift the items so that the first item starts on the right column?
Attached picture explains what I need.enter image description here

Upvotes: 2

Views: 273

Answers (1)

masp
masp

Reputation: 515

You shouldn't care about the position in the column based on the day of the week.

One way is to have one Date instance for each day. To show one year in the above form you need to have a gridview 7x52. First cell in the gridview will have the first day of the year. The second day will go to the second position etc.. You can also extract from that the day of the month to produce the result you want.

You will need headers for that. Check this http://blog.sqisland.com/2014/12/recyclerview-grid-with-header.html

One way to create days for the adapter of your grid:

For every day out of the 365 {
Calendar newDay = Calendar.getInstance();
newDay.set(Year, 2016);
newDay.set(Calendar.Day_Of_Year, 0<i<365);
Arraylist adaptersData.add(newDay);
{

Upvotes: 1

Related Questions