nambicompany / expandable-fab

A highly customizable 'speed dial' FloatingActionButton implementation.
https://nambicompany.github.io/expandable-fab/
MIT License
199 stars 20 forks source link

There is a varying margin between option buttons on screens with different dpi. #10

Closed mirzacharlie closed 3 years ago

mirzacharlie commented 3 years ago

Could you please change the margin of the buttons from px to dp? Alternatively, please add an option like "firstFabOptionMarginPx" for the other option buttons.

kabumere commented 3 years ago

Hey @mirzacharlie,

Could you please change the margin of the buttons from px to dp?

getDimension and getDimensionPixelSize methods of the Android SDK should help you convert DP to Pixels for use in the library. So you can retrieve your DP value and pass to one of the two methods above, and use the returned value when setting the margins.

Alternatively, please add an option like "firstFabOptionMarginPx" for the other option buttons.

firstFabOptionMarginPx is the margin between the first FabOption and the ExpandableFab button only. To change the margins between the other FabOptions, use successiveFabOptionMarginPx.

mirzacharlie commented 3 years ago

Hi, thx for your answer. This code works fine for me.

        val px = TypedValue.applyDimension(
            TypedValue.COMPLEX_UNIT_DIP,
            32f,
            resources.displayMetrics
        )
        fab.firstFabOptionMarginPx = px
        fab.successiveFabOptionMarginPx = px