判斷檔案是否存在:
public static boolean isFileExit(String path){ if(path == null){ return false; } try{ File f = new File(path); if(!f.exists()){ return false; } }catch (Exception e) { // TODO: handle exception } return true; }
ImageView的 android:scaleType屬性:
http://www.cnblogs.com/chorrysky/archive/2012/05/11/2496107.html
ImageView控制項中有一個android:scaleType屬性。
即ImageView.setScaleType(ImageView.ScaleType)
Sdk中介紹作用為:Options for scaling the bounds of an image to the bounds of this view.
大體意思為:一些縮放邊界來控製圖片視圖的界限範圍的選項
CENTERCenter the image in the view, but perform no scaling.按圖片的原來size置中顯示,當圖片長/寬超過View的長/寬,則截取圖片的置中部分顯示.CENTER_CROPScale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or larger than the corresponding dimension of the view (minus padding).按比例擴大圖片的size置中顯示,使得圖片長(寬)等於或大於View的長(寬)CENTER_INSIDEScale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or less than the corresponding dimension of the view (minus padding).將圖片的內容完整置中顯示,通過按比例縮小或原來的size使得圖片長/寬等於或小於View的長/寬FIT_CENTERScale the image using CENTER.把圖片按比例擴大/縮小到View的寬度,置中顯示FIT_ENDScale the image using END.把圖片按比例擴大/縮小到View的寬度,顯示在View的下部分位置FIT_STARTScale the image using START.把圖片按比例擴大/縮小到View的寬度,顯示在View的上部分位置FIT_XYScale the image using FILL.把圖片不按比例 擴大/縮小到View的大小顯示MATRIXScale using the image matrix when drawing.用矩陣來繪製