RecyclerView takes up all screenspace

后端 未结 2 834
隐瞒了意图╮
隐瞒了意图╮ 2020-12-18 12:05

So I\'m having some trouble with a RecyclerView in a layout file

Here it is:



        
2条回答
  •  长情又很酷
    2020-12-18 12:56

    When RecyclerView is drawn, it calculates all the remaining size on screen to itself before drawing the next elements and don't recalculate after the other elements are drawn, leaving them outside the screen.

    The trick is to draw all other elements first, and leave RecyclerView for last. FrameLayout does not work anymore so use a relative layout and put the RecyclerView last on the XML layout file.

    Example to add a bar with buttons below the RecyclerView:

    
    
    
         //HERE YOU ALIGN THIS ELEMENT TO THE BOTTOM OF THE PARENT
            

提交回复
热议问题