如何创建资源绘制对象 [英] How to create Drawable from resource
本文介绍了如何创建资源绘制对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个形象 RES /绘制/ test.png
(R.drawable.test)。
我想通过这个形象,它接受绘制对象
函数。
(例如mButton.setCompoundDrawables())
I have a image res/drawable/test.png
(R.drawable.test).
I want to pass this image to a function which accepts Drawable
.
(e.g. mButton.setCompoundDrawables())
那么如何将图像资源转换为绘制对象
?
So how to convert a image resource to an Drawable
?
推荐答案
您的活动应具备的方法getResources。做:
Your Activity should have the method getResources. Do:
Drawable myIcon = getResources().getDrawable( R.drawable.icon );
这篇关于如何创建资源绘制对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文