方法一:改变bitmap大小
public static Bitmap ResizeBitmap(Bitmap bitmap, int newWidth,int newHeight) {
if(null == bitmap)
return null;
int width = bitmap.getWidth();
int height = bitmap.getHeight();
float scaleWidth = ((float) newWidth) / width;
float scaleHeight = ((float) newHeight) / height;
Matrix matrix = new Matrix();
// resize the bit map
matrix.postScale(scaleWidth, scaleHeight);
Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height,
matrix, true);
return resizedBitmap;
}
方法二:改变view大小
根据density, 来重新调整view大小。
float density = Configuration.getDensity(mContext);
ViewGroup.LayoutParams llp = mAdLeft.getLayoutParams();
llp.width = new Float(225*density).intValue();
llp.height = new Float(120*density).intValue();
mAdLeft.setLayoutParams(llp);