99import android .graphics .PorterDuff ;
1010import android .graphics .drawable .BitmapDrawable ;
1111import android .graphics .drawable .GradientDrawable ;
12+ import android .graphics .drawable .VectorDrawable ;
1213import android .net .Uri ;
1314import android .os .Build ;
1415import android .os .Bundle ;
@@ -827,7 +828,6 @@ protected int getMaxWidth() {
827828 }
828829
829830 protected void updateIcon (ImageButton icon , @ DrawableRes int drawableRes ) {
830- VectorDrawableCompat drawable = (VectorDrawableCompat ) ContextCompat .getDrawable (this , drawableRes );
831831
832832 int [][] states = new int [][]{
833833 new int []{-android .R .attr .state_enabled }, // disabled
@@ -842,8 +842,17 @@ protected void updateIcon(ImageButton icon, @DrawableRes int drawableRes) {
842842 };
843843
844844 ColorStateList colorStateList = new ColorStateList (states , colors );
845- drawable .setTintList (colorStateList );
846- icon .setImageDrawable (drawable );
845+
846+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .LOLLIPOP ) {
847+ VectorDrawable drawable = (VectorDrawable ) ContextCompat .getDrawable (this , drawableRes );
848+ drawable .setTintList (colorStateList );
849+ icon .setImageDrawable (drawable );
850+
851+ } else {
852+ VectorDrawableCompat drawable = (VectorDrawableCompat ) ContextCompat .getDrawable (this , drawableRes );
853+ drawable .setTintList (colorStateList );
854+ icon .setImageDrawable (drawable );
855+ }
847856 }
848857
849858 @ Override
0 commit comments