1
我有一個可修改爲9的補丁作爲XML。當我嘗試使用BitmapFactory.decode
來獲取位圖時,它會返回null
。無論如何,從這個資源獲取位圖嗎?Android將Ninepatch資源轉換爲位圖
nine_patch.xml:
<?xml version="1.0" encoding="utf-8"?>
<nine-patch xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/empty_icon_video" >
</nine-patch>
而且代碼:
BitmapFactory.decodeResource(mResources, resId);
我的問題是,我從BitmapDrawable繼承,所以超級構造函數將位圖不ninepatchdraawable – youssefhassan
見編輯答案 – Triode