How can i implement custom section or header of ListView like Instagram app in android.
http://prsarahevans.com/wp-content/uploads/2011/06/photo.PNG
When scroll up the bar that have userpic, name and time still be there and when other header bar go near it then animate like push it up.
Thank you.
I was able to solve this issue by using scroll listener on the listview. (tested on 2.1)
Lets say for each list row I have a layout like the one below. There is a content part and a header part. It doesn't matter what view type you use for header or content.
The test layout for the activity is as in the following:
Finally the code for the activity is given below. Here I had to have an adapter which uses ViewHolder to store the header view and also a variable to keep track of the change in the scroll for each successive scroll events (previousTop). This is because of the fact that offsetTopAndBottom() changes offset of the view related to the previous location of it.
If you are using list view then have 2 views inside your list item. One is header and other is actually item.
Hide header view initially and as scroll state changes or user touches your list item change the visibility of header.
I've improved Siyamed's question a little bit so that the header is not gone when the view is redrawn for example if a bitmap in the listview item is changed.
Instead of using coordinates relative to the last position I use coordinates relative to the top of the view and use padding instead of offsets.
I know this question is a little old, but managed to find the StickyListHeaders library, which does a pretty good job of abstracting the creation of the section headers.
https://github.com/emilsjolander/StickyListHeaders
After your setcontentview do something like the below code.