日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
Android圖片大小調(diào)整動(dòng)態(tài)實(shí)現(xiàn)方法

Android操作系統(tǒng)中對(duì)于圖片的操作我們?cè)谝郧暗奈恼轮幸灿兴榻B。不過對(duì)于圖片的大小調(diào)整往往都局限于固定的調(diào)整。如何才能滿足動(dòng)態(tài)大小調(diào)整呢?我們?cè)谶@里就為大家詳細(xì)介紹有關(guān)Android圖片大小調(diào)整的動(dòng)態(tài)實(shí)現(xiàn)方法。

涿鹿ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場(chǎng)景,ssl證書未來市場(chǎng)廣闊!成為創(chuàng)新互聯(lián)的ssl證書銷售渠道,可以享受市場(chǎng)價(jià)格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:13518219792(備注:SSL證書合作)期待與您的合作!

昨天,動(dòng)態(tài)獲取圖片資源獲取的很爽啊,后來,換了一張png,128*128的,Run as android application,天哪,居然覆蓋了我大半個(gè)屏幕,都不留一點(diǎn)情面給我展示了。。。??磥恚仨氁覀€(gè)方法讓圖片自適應(yīng)大小,于是修改了一下獲取圖片的代碼,讓圖片能自適應(yīng)。

一下就是Android圖片大小調(diào)整的相關(guān)代碼示例:

 
 
 
  1. view plaincopy to clipboardprint?  
  2. private Bitmap getImageFromAssetFile(String fileName,int how){   
  3. Bitmap image = null ;   
  4. try {   
  5. AssetManager am = game.getAssets();   
  6. InputStream is = am.open(fileName);   
  7. image = BitmapFactory.decodeStream(is);   
  8. is.close();   
  9. }catch (Exception e){   
  10. }   
  11. return zoomImage(image,how);   
  12. }   
  13. public Bitmap zoomImage(Bitmap bgimage,int how) {   
  14. int bmpwidth = bgimage.getWidth();   
  15. int bmpheight = bgimage.getHeight();   
  16. float scaleWidth=0;   
  17. float scaleHeight=0;   
  18. Matrix matrix = new Matrix();   
  19. if(how==0){   
  20. scaleWidth = ((float) width) / bmpwidth;   
  21. scaleHeight = ((float) height) / bmpheight;   
  22. }else{   
  23. scaleWidth=Math.min(width,height)/bmpwidth;   
  24. scaleHeight=Math.min(width, height)/bmpheight;   
  25. }   
  26. private Bitmap getImageFromAssetFile(String fileName,int how){   
  27. Bitmap image = null ;   
  28. try {   
  29. AssetManager am = game.getAssets();   
  30. InputStream is = am.open(fileName);   
  31. image = BitmapFactory.decodeStream(is);   
  32. is.close();   
  33. }catch (Exception e){   
  34. }   
  35. return zoomImage(image,how);   
  36. }   
  37. public Bitmap zoomImage(Bitmap bgimage,int how) {  
  38. int bmpwidth = bgimage.getWidth();  
  39. int bmpheight = bgimage.getHeight();  
  40. float scaleWidth=0;  
  41. float scaleHeight=0;  
  42. Matrix matrix = new Matrix();  
  43. if(how==0){  
  44. scaleWidth = ((float) width) / bmpwidth;  
  45. scaleHeight = ((float) height) / bmpheight;  
  46. }else{  
  47. scaleWidth=Math.min(width,height)/bmpwidth;  
  48. scaleHeight=Math.min(width, height)/bmpheight;  
  49. }  

其中,scaleWidth和scaleHeight是欲縮放后的大小,這里加個(gè)參數(shù)how是防止有不需要縮放的情況~

Android圖片大小調(diào)整的操作方法就為大家介紹到這里。

【編輯推薦】

  1. Android界面互調(diào)具體應(yīng)用方式解析 
  2. Android智能指針使用方法介紹 
  3. Android查詢聯(lián)系人信息正確操作方法 
  4. Android命令行啟動(dòng)程序正確使用技巧解析 
  5. 全方位解讀Android多媒體框架源碼 

當(dāng)前名稱:Android圖片大小調(diào)整動(dòng)態(tài)實(shí)現(xiàn)方法
本文鏈接:http://www.5511xx.com/article/ccegshe.html