Floating Action Button Icon not centered inside

前端 未结 8 2475
鱼传尺愫
鱼传尺愫 2021-01-02 13:07

I\'m trying to use a FAB but the icon inside is placing at bottom right of the button:

FAB with icon not centered

This is the FAB definition in the xml:

相关标签:
8条回答
  • 2021-01-02 13:39

    If you're using material design and using custom sizes:

    android:layout_width="80dp"
    android:layout_height="80dp"
    

    instead of

    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    

    The fix is to use these two properties

    app:fabCustomSize="80dp"
    app:maxImageSize="70dp"
    

    make sure of this

    app:fabCustomSize = the same size as your layout_width
    app:maxImageSize= about 10dp minus the size of your layout_width
    
    0 讨论(0)
  • 2021-01-02 13:41

    Try

    android:width="wrap_content"
    android:height="wrap_content"
    app:maxImageSize ="56dp"
    

    on the fab. Worked for me

    0 讨论(0)
提交回复
热议问题