Android创建Drawable

根据文件路径创建Drawable

代码如下:

InputStream is=null;
try {
	//Return an AssetManager instance for your application's package
	is = _activity.getResources().getAssets().open("zres_back.png");
} catch (IOException e) {

}

Drawable drawable = Drawable.createFromStream(is,"zres_back.png");

下面这样创建返回null ,目前还不清楚原因。

Drawable drawable = Drawable.createFromPath("zres_back.png");

 

你可能感兴趣的:(Android)