Android: Create bigger Floating Action Button with bigger icon

前端 未结 8 666
陌清茗
陌清茗 2021-02-02 11:02

I want to create a bigger Floating Action Button (FAB), more than the usual 56 dp, with a bigger icon inside. (For my purpose an icon will never be self-explanatory so I will cr

8条回答
  •  感动是毒
    2021-02-02 11:25

    I stumbled across this and then found an answer through trial and error. It seems that you can increase the size of the floating action button if you set both layout:width and layout:height to match_parent and wrap the floating action button in a FrameLayout (doesn't have to be, but makes sense since you're only wanting to set the size of the button).

    Then set the FrameLayout width and height to whatever you desire.

    I upvoted Grace Coder's answer because it certainly addresses the problem but I thought this method would be safer and possibly more desirable.

    
    
        
    
    

    You can see the difference in this screenshot I took:

    The top FAB uses my code/workaround, whereas the bottom FAB uses the standard (mostly unchangeable) dimensions.

提交回复
热议问题