How can I add the new “Floating Action Button” between two widgets/layouts

前端 未结 10 2218
离开以前
离开以前 2020-11-22 10:31

I guess you have seen the new Android design guidelines, with the new \"Floating Action Button\" a.k.a \"FAB\"

For instance this pink button:

10条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-22 11:00

    Seems like the cleanest way in this example is to:

    • Use a RelativeLayout
    • Position the 2 adjacent views one below the other
    • Align the FAB to the parent right/end and add a right/end margin
    • Align the FAB to the bottom of the header view and add a negative margin, half the size of the FAB including shadow

    Example adapted from shamanland implementation, use whatever FAB you wish. Assume FAB is 64dp high including shadow:

    
    
    
        
    
        
    
        
    
    
    

    FAB Layout example

提交回复
热议问题