從輸入流啓動9修補程序可繪製的問題時遇到種種問題。我需要皮膚我的應用程序,並需要從Web服務下載皮膚元素和圖像。從輸入資源啓動9修補程序可繪製的問題
通過合理數量的資源在SO和Android開發者指南中尋找,但沒有一個對我有用。
設置從資源被拉伸並處理9patch妥善所謂邏輯的智慧這樣做是存在的,但由於某些原因,下面的代碼,我從Android源本身得出,未辦理9patch正確
Rect pad = new Rect();
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inScreenDensity = DisplayMetrics.DENSITY_DEFAULT;
Bitmap bm = BitmapFactory.decodeResourceStream(resources, typedValue, new FileInputStream(path), pad, opts);
if (bm != null) {
byte[] np = bm.getNinePatchChunk();
if (np == null || !NinePatch.isNinePatchChunk(np)) {
np = null;
pad = null;
}
if (np != null) {
drawable = new NinePatchDrawable(resources, bm, np, pad, path);
} else {
drawable = new BitmapDrawable(resources, bm);
}
}
我已將輸入源更改爲我的文件之一(FileInputStream(path)),在android源中它是在資源圖像上啓動的輸入源。
即使輸入圖像是9補丁,此代碼始終會返回BitmapDrawable。
有沒有人能成功實際獲取此功能的工作? 我會很感激任何幫助或提示解決方案。
預先感謝您。