如何将图像按钮的背景设置为用户拍摄的图片?

时间:2010-11-22 05:00:21

标签: android image background drawable imagebutton

我希望能够将xml文件中图像按钮的背景设置为用户在手机上拍摄的图片。

我将图片设置为cameraBitmap。

cameraBitmap = (Bitmap) intent.getExtras().get("data");

我希望将该图片传递给图像按钮的bakground。问题是,方法:setBackgroundDrawable()只能传递一个drawable。如何将Bitmap更改为可绘制图片并将其作为背景?

我目前有:

private ImageButton theImageButton;


theImageButton.setBackgroundDrawable(cameraBitmap);

1 个答案:

答案 0 :(得分:6)

如果您使用的是ImageButton,为什么不能使用此

theImageButton.setImageBitmap(cameraBitmap)