开发者

How do I set the background of an image button to a picture the user took?

开发者 https://www.devze.com 2023-01-26 11:28 出处:网络
I want to be able to set the background of an image button in an xml file to be the picture the user 开发者_开发知识库took on the phone.

I want to be able to set the background of an image button in an xml file to be the picture the user 开发者_开发知识库took on the phone.

I have the picture set as cameraBitmap.

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

and I want to pass that picture to be the bakground of the imagebutton. The problem is, the method: setBackgroundDrawable() only can pass in a drawable. How do I go about changing that Bitmap to a drawable picture and making it the background?

I currently have:

private ImageButton theImageButton;


theImageButton.setBackgroundDrawable(cameraBitmap);


If you are using ImageButton why can't you use this

theImageButton.setImageBitmap(cameraBitmap)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号