Scroll a View before ListView like lollipop phone app

时间:2015-05-28 12:49:38

标签: android listview android-recyclerview

I have a layout with a linearLayout (top layout) and a listview under this. What I want to do is like the phone app in Lollipop:

  • With the scrollbar I can scroll the contact list (top layout doesn't move)

  • When scroll the list with the finger, first the top layout is scrolling and once it is not visible anymore the listview scroll. When the top layout is visible the scrollbar doesn't move.

Someone has any idea how to do this trick?

What I'm thinking :

  • I can add the top layout to the header of listview, but the scrollbar take count of the header. And if I scroll with the scrollbar, the top layout will scroll

    • Trying to set a scrollListener to the listview, and translate the top view, but don't think it will be good and the scrollY is not available for listView

I think I can do something with a scrollView for the root layout, but I know it is not good to put a listview inside a scrollview.

I don't find any proper way to do this kind of feature...

EDIT: To be more clear, I want to translate the listview before I'm able to scroll the listview itself. Problem is when translate listview, the listview height will not expand.

1 个答案:

答案 0 :(得分:2)

我也在5.1版本的低版本中遇到了这个问题它工作正常。尝试在5.0中使用因为它是STABLE verson,还要检查5.1链接中的另一个滚动错误here我可以没有评论所以将此作为答案发布。