How to set Floating Action Button image to fill the button?

后端 未结 7 1488
情歌与酒
情歌与酒 2021-01-11 17:27

Usually icons are set for floating action buttons, but I need to set an image, so I can make a circular image.

I added it to the project (using Android Studio-> New

7条回答
  •  执念已碎
    2021-01-11 17:41

    The solution is app:maxImageSize = "56dp" property set to your FAB size.

    1. Have an image or vector asset, preferably in perfect circle shape and perfectly fit to canvass (no empty margins).
    2. Know the actual size of Floating Action Bar (FAB) - Default (56 x 56dp) or Mini (40 x 40dp).
    3. XML Code thusly:
    
    

提交回复
热议问题