문제

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)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top