9
我有一個視圖。我想放置一個位圖圖像作爲它的背景圖像。我無法做到這一點。將位圖作爲視圖的背景
//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
任何人都可以幫忙嗎?
我可以放置一個位圖作爲背景的視圖 – James 2010-10-03 16:23:51
只需直接調用'setBackgroundResource(R.drawable.grape)'。 – JRL 2010-10-03 16:27:45
但實際上我需要在那裏放置一個位圖。有沒有辦法做到這一點。 – James 2010-10-03 16:37:49