谷歌照片应用程序时间轴功能使用他们创建时的图像年份

Aka*_*iya 5 android timeline scroll photos android-recyclerview

我想在回收站视图中实现谷歌照片应用程序时间轴功能,我们可以在创建它们时滚动多年的图像,如下图所示.

谷歌照片年度时间线功能

任何人都可以帮助这个或实现这样的事情.

Aka*_*iya 1

我已经解决了这个问题,方法是简单地在 recyclerview 顶部添加一个新的线性布局,并在布局中添加一个子文本视图,然后计算相对于可用总高度的高度比(根据每年的图像数量)。如果比例太小,还要考虑将 textview 的最小高度设置为 100。

private float getEffectiveHeight(float totalHeight, float count, float totalCount) {
    if (count * (totalHeight / totalCount) < 100)
        return 100;
    else
        return count * (totalHeight / totalCount);
}
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述