Adjust icon size of Floating action button (fab)

后端 未结 11 1301
名媛妹妹
名媛妹妹 2020-11-29 17:21

\"Floating The new floating action button should be 56dp x 56dp and the icon inside it should

11条回答
  •  醉话见心
    2020-11-29 17:47

    There are three key XML attributes for custom FABs:

    • app:fabSize: Either "mini" (40dp), "normal"(56dp)(default) or "auto"
    • app:fabCustomSize: This will decide the overall FAB size.
    • app:maxImageSize: This will decide the icon size.

    Example:

    app:fabCustomSize="64dp" 
    app:maxImageSize="32dp"
    

    The FAB padding (the space between the icon and the background circle, aka ripple) is calculated implicitly by:

    4-edge padding = (fabCustomSize - maxImageSize) / 2.0 = 16
    

    Note that the margins of the fab can be set by the usual android:margin xml tag properties.

提交回复
热议问题