如何将图像按钮的背景设置为用户拍摄的照片?
我希望能够将 xml 文件中的图像按钮的背景设置为用户在手机上拍摄的图片。
我将图片设置为cameraBitmap。
cameraBitmap = (Bitmap) intent.getExtras().get("data");
我想传递该图片作为图像按钮的背景。问题是,方法:setBackgroundDrawable()
只能传入一个drawable。我该如何将该位图更改为可绘制图片并将其设为背景?
我目前有:
private ImageButton theImageButton;
theImageButton.setBackgroundDrawable(cameraBitmap);
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);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您正在使用 ImageButton 为什么不能使用它
If you are using ImageButton why can't you use this