根据屏幕的长度和宽度设置图像的显示
Display currentDisplay=getWindowmanager().getDefaultDisplay();
int dw=currentDisplay.getWidth();
int dh=currentDisplay.getHeight();
BitmapFactory.options bmpFactoryOptions=new BitmapFactory.Options();
bmpFactoryOptions.inJustDecodeBounds=true;
Bitmap bmp=BitmapFactory.decodeFile(imageFilePath,bmpFactoryOptions);
int heightRatio=(int)Math.ceil(bmpFactoryOptions.outHeight/(float)dh);
int widthRation=(int)Math.ceil(bmpFactoryOptions.outWidth/(float)dw);
//if(heightRation>1&&widthRatio>1){
if(heightRation>widthRatio){
//若高度比率更大,则根据它进行缩放
bmpFactoryOptions.insampleSize=heightRatio;
}ele{
//若宽度比率更大,则根据它进行缩放
bmpFactoryOptions.insampleSize=widthRatio;
}
bmpFactoryOptions.inJustDecodeBounds=false;
bmp=BitmapFactory.decodeFile(imageFilePath,bmpFactoryOptions);