Create scroll layout like Instagram

跟風遠走 提交于 2019-12-06 12:41:53

问题


I want to design a app which have a new feed screen like Instagram app.

If you have used Instagram you can see when you scroll up the toolbar will push up and replaced by header of feed. (Ok, I can do it which android support design) .

When you continue scroll, the header of the second feed will push up and replace the header of the first. I wonder how can they do that ? How can they detect when an item is over ?

This video demo how instagram app scroll :

https://www.youtube.com/watch?v=ThzZlrKVY-g

Sorry about my grammar, Thank in advanced !!!


回答1:


I think you're leaning towards Sticky Headers. There are many existing lightweight libraries out there that will make your life easier.

Check out StickyHeadersRecycleView (Has a GIF to show how it works)

Alternate option, also a library.. StickyHeader




回答2:


You could try these steps. I've done it before using this steps.

1.) Create a ScrollView on your main layout with LinearLayout inside it
2.) Create a Fragment for a layout you need (Image and a comment section below)
3.) On your MainActivity Inflate the fragment inside the LinearLayout as much as you need(inflate the fragment for each images).



来源:https://stackoverflow.com/questions/32720544/create-scroll-layout-like-instagram

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!