Display content under toolbar

后端 未结 3 1633
旧时难觅i
旧时难觅i 2021-02-04 02:14

Hello I\'m attempting to simply put my content below the toolbar but at the moment when I run my application some of the content is hidden behind it when it should be below it.<

3条回答
  •  梦如初夏
    2021-02-04 02:18

    Many ViewGroups allow their children to overlap. These include FrameLayout, RelativeLayout, CoordinatorLayout, and DrawerLayout. One that does not allow its children to overlap is LinearLayout.

    The answer to your question really depends on what the end result should be. If you are trying to just have a Toolbar that is always on screen and some content below it, then you don't need a CoordinatorLayout and AppBarLayout at all, you can just use a vertical LinearLayout with two children:

    
        
    
        
    
    

    Note layout attributes of the FrameLayout.

    If you want to do the fancy stuff where the toolbar scrolls on and off the screen as you scroll the content, then you need an AppBarLayout and you need to give your content area a special attribute like this:

    
        
    
            
        
    
        
    
    

提交回复
热议问题