7

I want to implement the google photos application timeline feature in the recycler view in which we can show the year of images as a label while scrolling as shown in below image.

google photos year timeline feature

Can anyone help in this or implemented something like this.

Akash Bisariya
  • 3,855
  • 2
  • 30
  • 42
  • 1
    Please show what you have already tried and what specific issues you are running into. This is not a "how to" forum. – Dan Harms Jun 06 '18 at 22:26
  • I am currently trying to implement that but I have no idea of implementing this.I got to know that it is known as date-scrubber feature. – Akash Bisariya Jun 07 '18 at 04:28
  • Agree with dharms. Your first clue is to inspect similar libraries, e.g. [this one](https://github.com/timusus/RecyclerView-FastScroll). – azizbekian Jun 10 '18 at 13:31

1 Answers1

1

I have solved this problem by simply adding a new Linear-layout on top of the recyclerview with a child textview in the layout and then by calculating the height ratio(as per the count of images per year) with respect to the total height available.Also considering the minimum height of textview to 100 if the ratio is too small.

private float getEffectiveHeight(float totalHeight, float count, float totalCount) {
    if (count * (totalHeight / totalCount) < 100)
        return 100;
    else
        return count * (totalHeight / totalCount);
}

enter image description here

Akash Bisariya
  • 3,855
  • 2
  • 30
  • 42