亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Android 加載asset文件夾下邊的圖片

 更新時(shí)間:2017年02月08日 17:11:17   作者:AngleElina  
這篇文章主要介紹了Android 加載asset文件夾下邊的圖片,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下

將asset中的圖片文件加載到ImageView中

// load image  
    try {  
      // get input stream  
      InputStream ims = getAssets().open("avatar.jpg");  
      // load image as Drawable  
      Drawable d = Drawable.createFromStream(ims, null);  
      // set image to ImageView  
      mImage.setImageDrawable(d);  
    }  
    catch(IOException ex) {  
      return;  
    }  

將asset中的圖片文件繪制到自定義View中。

Bitmap bitmap; 
    try {  
      InputStream ims = this.getContext().getAssets().open("fl.jpg");  
      // 讀入圖片并將其強(qiáng)轉(zhuǎn)為 BitmapDrawable類(lèi)型 
      BitmapDrawable bd = (BitmapDrawable) Drawable.createFromStream(ims, null); 
      bitmap = bd.getBitmap(); 
      ims.close(); 
    }  
    catch(IOException ex) {  
      return;  
    }  
    //canvas.drawBitmap(bitmap, -200, -200, new Paint()); 
    canvas.drawBitmap(bitmap, null, new Rect(-30,-40,30,40), new Paint());//null表示原圖尺寸,第二個(gè)rect表示顯示區(qū)域(位圖會(huì)拉伸填充該區(qū)域) 

以上所述是小編給大家介紹的Android 加載asset文件夾下邊的圖片,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評(píng)論