Android google-play-liked listview

2019-08-29 11:31发布

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

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 ) enter image description here

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

2条回答
淡お忘
2楼-- · 2019-08-29 12:04

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.

查看更多
登录 后发表回答