Skip to content

Commit 51c4b1e

Browse files
Fix issue #37
1 parent 169f64c commit 51c4b1e

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

library/src/main/java/com/thefinestartist/finestwebview/FinestWebViewActivity.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import android.graphics.PorterDuff;
1010
import android.graphics.drawable.BitmapDrawable;
1111
import android.graphics.drawable.GradientDrawable;
12+
import android.graphics.drawable.VectorDrawable;
1213
import android.net.Uri;
1314
import android.os.Build;
1415
import 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

Comments
 (0)