Android google-play-liked listview

2019-08-29 11:46发布

问题:

Im new to android and practicing with an UI like googleplay apps, this is default view of the list :

when i scroll the list view up , the action bar got scrolled up and disappeared , basically my English is too bad and i dont know how or which keyword i must use in google search to get the result like this (as you see it looks like the action bar is inside the listview )

please show me how or give me an example to learn, thank you !

回答1:

you can define your layout structure like following :

<FrameLayout>

    <GridView or RecyclerView/>

    <MenuBar id="menuBar2" visibility="gone"/>

</FrameLayout>

to making the grid be able to scroll with the TitleBar and MenuBar, we should add a Header with GridView, of course RecyclerView would be easier to do this than GridView. the Header layout's structure would be like this :

<LinearLayout orientation="vertical">

    <TitleBar/>

    <MenuBar id="menuBar1"/>

</LinearLayout>

Once the menuBar1 fully scroll off to invisible, display the menuBar2, also synchronizing the menu state between both. The menuBar2 will appearing on top of that LinearLayout. when user scrolling to top and the menuBar1 just visible, hide the menuBar2.

how to determine if a View is fully invisible? the View.getLocalVisibleRect() would tell for this.



回答2:

Check How do the animation hiding the ActionBar and keeping tabs?

It suggests that you use https://github.com/ksoichiro/Android-ObservableScrollView.