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

Sap*_*app 1 android background image imagebutton drawable

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

我将图片设置为cameraBitmap.

cameraBitmap = (Bitmap) intent.getExtras().get("data");
Run Code Online (Sandbox Code Playgroud)

我想把那张照片传递给imagebutton的bakground.问题是,方法: setBackgroundDrawable()只能传入drawable.如何将Bitmap更改为可绘制图片并将其作为背景?

我目前有:

private ImageButton theImageButton;


theImageButton.setBackgroundDrawable(cameraBitmap);
Run Code Online (Sandbox Code Playgroud)

Lab*_*lan 6

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

theImageButton.setImageBitmap(cameraBitmap)
Run Code Online (Sandbox Code Playgroud)