这哪里是绘制在什么位置? [英] Where is this drawable located?
问题描述
我用从的code这个答案和编译一切顺利。
I used the code from this answer, and compiled everything successfully.
不过,我无法找出如何使用我刚才创建的绘制。这是我的code:
However, I cannot find out how to use the drawable that I have just created. Here is my code:
Drawable dr2 = getResources().getDrawable(android.R.drawable.ic_menu_manage);
Bitmap bitmap2 = ((BitmapDrawable) dr2).getBitmap();
Drawable f = new BitmapDrawable(getResources(), Bitmap.createScaledBitmap(bitmap2, 256, 256, true));
private Integer[] menu_icon = {
android.R.drawable.f,
// I can't figure out how to call Drawable f
};
在绘制转换为后绘制对象˚F
,我无法找出如何召回大小绘制。我已经用我的code所有可能的位置在何处也可能是(/ RES /绘制和其他几个地点)尝试。但是,我无法编译无论我怎么尝试调用可绘制F。任何帮助将大大AP preciated!
After converting the drawable to the Drawable f
, I am unable to find out how to recall the resized drawable. I have tried using all possible locations in my code as to where it may be (/res/drawable and a few other locations). However, I am unable to compile no matter how I try to call Drawable f. Any help would be greatly appreciated!
(不,我在该数组八素,但只复制+粘贴一个)
(And no, I have eight elements in that array, but only copy+pasted one)
推荐答案
它只存在于内存中,没有任何地方在磁盘上。通过ID不能引用它。相反,你需要调用的,它接受一个绘制对象,而不是那些需要一个int RESOURCEID功能的版本。
It exists only in memory, not anywhere on disk. You can't reference it by id. Instead, you need to call versions of functions that take a Drawable rather than ones that take an int resourceID.
这篇关于这哪里是绘制在什么位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!