nambicompany / expandable-fab

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

Button drawable shifted #6

Closed neroux closed 3 years ago

neroux commented 3 years ago

Hi Kelvin,

Using the following drawable for the main button the image is originaly rendered fine, though the moment it is clicked (and re-renders the image) the image is not centred any more but shifted off.

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="30dp"
    android:height="30dp"
    android:viewportWidth="24"
    android:viewportHeight="24">
    <path
        android:fillColor="@android:color/white"
        android:pathData="M12,8c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2zM12,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM12,16c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2z" />
</vector>

It appears to happen because the dimensions do not match the viewport dimensions (30 vs 24) but that's exactly what Android Studio generated (when choosing 30), so I wouldn't not assume the definition is invalid per se.

kabumere commented 3 years ago

Hey @neroux,

If your drawable's height and width are different from its viewportHeight and viewportWidth, set app:maxImageSize on the ExpandableFab equal to the width/height of the drawable. So in your instance, set app:maxImageSize to 30dp. This is an attribute from the Android SDK.

neroux commented 3 years ago

Thanks Kelvin, that did the trick

vishalbhanderii commented 1 year ago

Hey @neroux,

If your drawable's height and width are different from its viewportHeight and viewportWidth, set app:maxImageSize on the ExpandableFab equal to the width/height of the drawable. So in your instance, set app:maxImageSize to 30dp. This is an attribute from the Android SDK.

@kabumere You should mention this in the installation guide. Please