我想将位图颜色设置为src
。但我的颜色没有显示,只是空屏幕。我试图做
mIcon11 = BitmapFactory.decodeResource(getResources(), R.color.grey);
如果我写R.drawable.imageName
它会显示图像,为什么我的颜色没有显示?
我的颜色是:
<resources>
<color name="grey">#696969</color>
</resources>
答案 0 :(得分:3)
作为Bitmap
:
int bitmapWidth = ...
int bitmapHeight = ....
Bitmap mIcon11 = Bitmap.createBitmap(bitmapWidth, bitmapHeight, Bitmap.Config.ARGB_8888);
mIcon11.eraseColor(getResources().getColor(R.color.grey));
。
由于它是一种颜色,因此您不需要Bitmap
。您可能最好只将其加载为Drawable
:
Drawable mIcon11 = getResources().getDrawable(R.color.grey);
答案 1 :(得分:-1)