我有一个观点.我想将位图图像作为其背景图像.我无法做到这一点.
//My code is below
Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.grape);
part1 = new View(this);
Bitmap map2 = Bitmap.createBitmap(targetWidth, targetHeight,Bitmap.Config.ARGB_8888);
canvas.drawBitmap( bitmapOrg,new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()), new Rect(0, 0, targetWidth, targetHeight), null);
part1.setBackgroundResource(map2); //i couldn't place map2 as bgresource to my view part1
Run Code Online (Sandbox Code Playgroud)
有人可以帮忙吗?
JRL*_*JRL 18
根据API文档,setBackgroundResource期望一个int.
如果你肯定需要一个位图,你可以使用它setBackgroundDrawable来包装你的位图BitmapDrawable.
| 归档时间: |
|
| 查看次数: |
17931 次 |
| 最近记录: |