File tree Expand file tree Collapse file tree 1 file changed +14
-12
lines changed
core/java/com/android/internal/view/menu Expand file tree Collapse file tree 1 file changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -141,19 +141,21 @@ private void updateTextButtonVisibility() {
141141
142142 public void setIcon (Drawable icon ) {
143143 mIcon = icon ;
144- int width = icon .getIntrinsicWidth ();
145- int height = icon .getIntrinsicHeight ();
146- if (width > mMaxIconSize ) {
147- final float scale = (float ) mMaxIconSize / width ;
148- width = mMaxIconSize ;
149- height *= scale ;
150- }
151- if (height > mMaxIconSize ) {
152- final float scale = (float ) mMaxIconSize / height ;
153- height = mMaxIconSize ;
154- width *= scale ;
144+ if (icon != null ) {
145+ int width = icon .getIntrinsicWidth ();
146+ int height = icon .getIntrinsicHeight ();
147+ if (width > mMaxIconSize ) {
148+ final float scale = (float ) mMaxIconSize / width ;
149+ width = mMaxIconSize ;
150+ height *= scale ;
151+ }
152+ if (height > mMaxIconSize ) {
153+ final float scale = (float ) mMaxIconSize / height ;
154+ height = mMaxIconSize ;
155+ width *= scale ;
156+ }
157+ icon .setBounds (0 , 0 , width , height );
155158 }
156- icon .setBounds (0 , 0 , width , height );
157159 setCompoundDrawables (icon , null , null , null );
158160
159161 updateTextButtonVisibility ();
You can’t perform that action at this time.
0 commit comments