Floating action button not displaying over recyclerview(which is inside a DrawerLayout)

前端 未结 5 1371
[愿得一人]
[愿得一人] 2021-02-19 00:30

I am trying to get FAB over recyclerview which in my case will cover the whole screen. The FAB wont display even recyclerview is empty. Following is my xml code.



        
5条回答
  •  野的像风
    2021-02-19 01:19

    Try it like this :

    Remove all layouts.

    Keep only one parent, that's CoordinatorLayout.

    Inside CoordinatorLayout, put both your RecyclerView and FloatingActionButton.

    CoordinatorLayout should auto arrange your toolbar, recycler and fab, since is programmed to handle the design support library components.

    Here's an example. You can use RecyclerView in place of the FrameLayout (which dynamically loads fragments at runtime). I generally use RecyclerView in another Fragment and load the fragment in here at runtime. This keeps the xml files clean.

    
    
    
    
        
    
            
    
        
    
    
        
        
    
        
    
        
    
    
    
    
    
    
    
    
    

提交回复
热议问题