自定义以下方法:
public Bitmap decodeResouce(Resources resources, int id){ BitmapFactory.Options options = new BitmapFactory.Options(); TypedValue value=new TypedValue(); getResources().openRawResource(id,value); options.inTargetDensity = value.density;//float scale = targetDensity / (float)density;//缩放比例 return BitmapFactory.decodeResource(resources, id,options); }
设置options.inTargetDensity = value.density;让scale为1就不会出现缩放问题了。