内射老阿姨1区2区3区4区_久久精品人人做人人爽电影蜜月_久久国产精品亚洲77777_99精品又大又爽又粗少妇毛片

Android中怎么動態(tài)調(diào)整圖片大小

Android中怎么動態(tài)調(diào)整圖片大小,相信很多沒有經(jīng)驗的人對此束手無策,為此本文總結(jié)了問題出現(xiàn)的原因和解決方法,通過這篇文章希望你能解決這個問題。

創(chuàng)新互聯(lián)擁有網(wǎng)站維護(hù)技術(shù)和項目管理團隊,建立的售前、實施和售后服務(wù)體系,為客戶提供定制化的網(wǎng)站設(shè)計制作、成都網(wǎng)站制作、網(wǎng)站維護(hù)、成都移動機房托管解決方案。為客戶網(wǎng)站安全和日常運維提供整體管家式外包優(yōu)質(zhì)服務(wù)。我們的網(wǎng)站維護(hù)服務(wù)覆蓋集團企業(yè)、上市公司、外企網(wǎng)站、商城網(wǎng)站制作、政府網(wǎng)站等各類型客戶群體,為全球1000多家企業(yè)提供全方位網(wǎng)站維護(hù)、服務(wù)器維護(hù)解決方案。

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

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

view plaincopy to clipboardprint?  private Bitmap getImageFromAssetFile(String fileName,int how){   Bitmap image = null ;   try {   AssetManager am = game.getAssets();   InputStream is = am.open(fileName);   image = BitmapFactory.decodeStream(is);   is.close();   }catch (Exception e){   }   return zoomImage(image,how);   }   public Bitmap zoomImage(Bitmap bgimage,int how) {   int bmpwidth = bgimage.getWidth();   int bmpheight = bgimage.getHeight();   float scaleWidth=0;   float scaleHeight=0;   Matrix matrix = new Matrix();   if(how==0){   scaleWidth = ((float) width) / bmpwidth;   scaleHeight = ((float) height) / bmpheight;   }else{   scaleWidth=Math.min(width,height)/bmpwidth;   scaleHeight=Math.min(width, height)/bmpheight;   }   private Bitmap getImageFromAssetFile(String fileName,int how){   Bitmap image = null ;   try {   AssetManager am = game.getAssets();   InputStream is = am.open(fileName);   image = BitmapFactory.decodeStream(is);   is.close();   }catch (Exception e){   }   return zoomImage(image,how);   }   public Bitmap zoomImage(Bitmap bgimage,int how) {  int bmpwidth = bgimage.getWidth();  int bmpheight = bgimage.getHeight();  float scaleWidth=0;  float scaleHeight=0;  Matrix matrix = new Matrix();  if(how==0){  scaleWidth = ((float) width) / bmpwidth;  scaleHeight = ((float) height) / bmpheight;  }else{  scaleWidth=Math.min(width,height)/bmpwidth;  scaleHeight=Math.min(width, height)/bmpheight;  }

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

看完上述內(nèi)容,你們掌握Android中怎么動態(tài)調(diào)整圖片大小的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!

網(wǎng)站名稱:Android中怎么動態(tài)調(diào)整圖片大小
轉(zhuǎn)載注明:http://www.rwnh.cn/article12/jihogc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制開發(fā)、品牌網(wǎng)站制作微信公眾號、服務(wù)器托管、品牌網(wǎng)站設(shè)計、Google

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站制作
南平市| 江川县| 新化县| 襄汾县| 郓城县| 新民市| 肇源县| 宝坻区| 怀仁县| 宝应县| 敦煌市| 开封县| 金川县| 龙州县| 马尔康县| 龙海市| 乌鲁木齐市| 新竹市| 小金县| 普格县| 兴业县| 凤凰县| 南昌县| 华安县| 丰镇市| 登封市| 宁津县| 永定县| 屏东市| 武胜县| 桃园市| 阿巴嘎旗| 蓝田县| 宜阳县| 祁连县| 遵化市| 安图县| 鄂托克旗| 张家川| 禄劝| 凤翔县|