android 把bitmap转成drawble后宽高不一致的解决方法

DisplayMetrics metrics = new DisplayMetrics();
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Resources r = new Resources(context.getAssets(), metrics, null);
windowManager.getDefaultDisplay().getMetrics(metrics);
Drawable bgDrawble2 = new BitmapDrawable(r, bgBitmap);

你可能感兴趣的:(android 把bitmap转成drawble后宽高不一致的解决方法)