Tabbar icon indicating copy to clipboard operation
Tabbar copied to clipboard

将vector图片转为 bitmap时为null的问题

Open muzidudu opened this issue 4 years ago • 0 comments

修复方法 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; }

muzidudu avatar Sep 24 '20 02:09 muzidudu