Skip to content

Commit 93394c7

Browse files
committed
Fix main FAB opened icon not showing on old Android versions
1 parent 57a8347 commit 93394c7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

library/src/main/java/com/leinardi/android/speeddial/SpeedDialView.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import android.content.Context;
2020
import android.content.res.ColorStateList;
2121
import android.content.res.TypedArray;
22+
import android.graphics.Bitmap;
2223
import android.graphics.Rect;
2324
import android.graphics.drawable.Drawable;
2425
import android.os.Build;
@@ -806,7 +807,10 @@ private void toggle(boolean show, boolean animate) {
806807
private void updateMainFabDrawable(boolean animate) {
807808
if (isOpen()) {
808809
if (mMainFabOpenedDrawable != null) {
809-
mMainFab.setImageDrawable(mMainFabOpenedDrawable);
810+
// This is a workaround. I don't know why if I set directly the rotated Drawable with `setImageDrawable`
811+
// it will be transparent/empty on Android API 16 (works on API 27, haven't tested other versions).
812+
Bitmap bitmap = UiUtils.getBitmapFromDrawable(mMainFabOpenedDrawable);
813+
mMainFab.setImageBitmap(bitmap);
810814
}
811815
UiUtils.rotateForward(mMainFab, getMainFabAnimationRotateAngle(), animate);
812816
} else {

0 commit comments

Comments
 (0)