Android - Scroll/Move the ListView itself

前端 未结 2 1143
广开言路
广开言路 2021-01-21 04:36

I have seen some modern Android and iOS applications where there will be an Image at the top of the page that covers the entire width of the screen. Beneath it, there will be a

2条回答
  •  不知归路
    2021-01-21 05:18

    This is a bit of visual trickery, where it seems as the image and list are one but they are really not.

    basically you have a listview with a headerview the same size as the image and below the listview you have your image so as you scroll it appears the listview is scrolling over the image.

    The layout would look something like this

    
    
        
    
        
    
    
    

    The create another layout for the header that is empty with the size of the imageview

    You can also Translate the image in the Y direction when the list scrolls but then you have to hold onto the view globally in your class so you can translate using v.setTranslateY()

提交回复
热议问题