2013年1月3日

[Android]平版安裝不了驅動


問題:


開發Android時,使用模擬器是一件使人磨耐性的事。而且模擬器的功能始終有限,平版市場充斥。許多USB-Driver一直安裝不上去。

解決:

(適用 Win7 & WinXP)

修改Google USB Driver 的 [android_winusb.inf]
讓您的平版也可以安裝上去。

Step 1:
打開android_winusb.inf 檔案。

筆者的路徑為:C:\Android\android-sdk\extras\google\usb_driver\

Step 2:
打開裝置管理員,未知裝置->(右鍵)內容->詳細資料->選擇硬體辨識碼

Step 3:
確定電腦為x64 or x86 ->尋找


[Google.NTx86]

[Google.NTamd64]

按照上面的方式,將資訊填入


;Android
%SingleAdbInterface%        = USB_Install, USB\VID_18D1&PID_0003&REV_0230&MI_01
%SingleAdbInterface%        = USB_Install, USB\VID_18D1&PID_0003&MI_01

Step 4:
重新更新驅動,會發現安裝成功。

Step 5:
清除adb並重新啟動
清除adb:開始->執行->CMD->輸入 cd C:\Android\android-sdk\platform-tools\adb kill-server
重新啟動:開始->執行->CMD->輸入 cd C:\Android\android-sdk\platform-tools\adb start

Done.

2013年1月1日

[Android]製作縮圖

問題:
在使用Android的ImageView元件放入圖檔時,發現圖檔尺寸比ImageView元件的尺寸來的大很多。

解決:
使用Android製作縮圖,



/**
 原始圖檔 bitmap
*/

//取得圖檔寬度
int bmpWidth  = bitmap.getWidth(); 

//取得圖檔高度
int bmpHeight  = bitmap.getHeight(); 

//設定縮圖寬度
float scaleWidth  = (float) sWidth / bmpWidth;     
//按固定大小缩放sWidth,要多大有多大

//設定縮圖高度
float scaleHeight = (float) sHeight / bmpHeight;  

//轉換矩陣
Matrix matrix = new Matrix(); 
matrix.postScale(scaleWidth, scaleHeight); 

//產生縮圖
Bitmap resizeBitmap = 
Bitmap.createBitmap(bitmap, 0, 0, bmpWidth, bmpHeight,matrix, false); 

//記得做資源回收,不然會發生溢位
bitmap.recycle(); 


參考網站:Android中图片缩放方法