Tabbar
Tabbar copied to clipboard
将vector图片转为 bitmap时为null的问题
修复方法
public Tab setIcon(@Nullable Context context, @DrawableRes int resId) { Bitmap bitmap=null; if (Build.VERSION.SDK_INT>Build.VERSION_CODES.LOLLIPOP){ Drawable vectorDrawable = context.getDrawable(resId); bitmap = Bitmap.createBitmap(vectorDrawable.getIntrinsicWidth(), vectorDrawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); vectorDrawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); vectorDrawable.draw(canvas); }else { bitmap = BitmapFactory.decodeResource(context.getResources(), resId); } this.icon = bitmap; return this; }