25
25
/**
26
26
* Created by cym on 14-8-2.
27
27
*/
28
- public class FloatingActionButton extends View {
28
+ public class FloatActionButton extends View {
29
29
30
30
final static OvershootInterpolator overshootInterpolator = new OvershootInterpolator ();
31
31
final static AccelerateInterpolator accelerateInterpolator = new AccelerateInterpolator ();
@@ -36,7 +36,7 @@ public class FloatingActionButton extends View {
36
36
Bitmap mBitmap ;
37
37
boolean mHidden = false ;
38
38
39
- public FloatingActionButton (Context context ) {
39
+ public FloatActionButton (Context context ) {
40
40
super (context );
41
41
this .context = context ;
42
42
init (Color .WHITE );
@@ -47,7 +47,18 @@ public void setFloatingActionButtonColor(int FloatingActionButtonColor) {
47
47
}
48
48
49
49
public void setFloatingActionButtonDrawable (Drawable FloatingActionButtonDrawable ) {
50
- mBitmap = ((BitmapDrawable ) FloatingActionButtonDrawable ).getBitmap ();
50
+ // mBitmap = ((BitmapDrawable) FloatingActionButtonDrawable).getBitmap();
51
+
52
+
53
+ if (FloatingActionButtonDrawable instanceof BitmapDrawable ) {
54
+ mBitmap = ((BitmapDrawable )FloatingActionButtonDrawable ).getBitmap ();
55
+ }else {
56
+ Bitmap bitmap = Bitmap .createBitmap (FloatingActionButtonDrawable .getIntrinsicWidth (),FloatingActionButtonDrawable .getIntrinsicHeight (), Bitmap .Config .ARGB_8888 );
57
+ Canvas canvas = new Canvas (bitmap );
58
+ FloatingActionButtonDrawable .setBounds (0 , 0 , canvas .getWidth (), canvas .getHeight ());
59
+ FloatingActionButtonDrawable .draw (canvas );
60
+ mBitmap = bitmap ;
61
+ }
51
62
invalidate ();
52
63
}
53
64
@@ -175,8 +186,8 @@ public Builder withButtonSize(int size) {
175
186
return this ;
176
187
}
177
188
178
- public FloatingActionButton create () {
179
- final FloatingActionButton button = new FloatingActionButton (activity );
189
+ public FloatActionButton create () {
190
+ final FloatActionButton button = new FloatActionButton (activity );
180
191
button .setFloatingActionButtonColor (this .color );
181
192
button .setFloatingActionButtonDrawable (this .drawable );
182
193
params .gravity = this .gravity ;
0 commit comments