【android】 判斷文件是否存在,ImageView scaletype


判斷文件是否存在:

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.
大體意思為:一些縮放邊界來控制圖片視圖的界限范圍的選項

CENTER
Center the image in the view, but perform no scaling.
按圖片的原來size居中顯示,當圖片長/寬超過View的長/寬,則截取圖片的居中部分顯示.

CENTER_CROP
Scale 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_INSIDE
Scale 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_CENTER
Scale the image using CENTER.
把圖片按比例擴大/縮小到View的寬度,居中顯示

FIT_END
Scale the image using END.
把圖片按比例擴大/縮小到View的寬度,顯示在View的下部分位置

FIT_START
Scale the image using START.
把圖片按比例擴大/縮小到View的寬度,顯示在View的上部分位置

FIT_XY
Scale the image using FILL.
把圖片不按比例 擴大/縮小到View的大小顯示

MATRIX
Scale using the image matrix when drawing.
用矩陣來繪制


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM