search

Home  >  Q&A  >  body text

android - RecyclerView 添加了一个超长的header后,scrollbar的大小和比例不对。

用viewType实现的header。
header的高度有三四屏高,其它的view高度就几十像素。
当滚动到header部分后,scrollbar的位置和大小明显都不对,看起来非常小。
是否有方法能实现自己计算:实际滚动距离 /(header尺寸 + item数 * item尺寸)获得移动的比例,然后自己设置滚动条的高度什么的?

高洛峰高洛峰2772 days ago722

reply all(1)I'll reply

  • PHPz

    PHPz2017-04-17 17:40:51

    Let me tell you the reason first,
    Because RecyclerView actually loads the page dynamically. When your head is slid out of the screen, it may be destroyed and will not be counted in the entire sliding view.
    If you want to achieve the effect you want, you might as well hide the built-in slider and make one yourself. It should be very simple

    reply
    0
  • Cancelreply