【问题标题】:How do I set the background of an image button to a picture the user took?如何将图像按钮的背景设置为用户拍摄的图片?
【发布时间】:2010-11-22 05:00:21
【问题描述】:

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

我将图片设置为cameraBitmap。

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

我想将该图片作为图像按钮的背景。问题是,方法:setBackgroundDrawable() 只能传入一个drawable。如何将该位图更改为可绘制图片并使其成为背景?

我目前有:

private ImageButton theImageButton;


theImageButton.setBackgroundDrawable(cameraBitmap);

【问题讨论】:

    标签: android image background drawable imagebutton


    【解决方案1】:

    如果你使用 ImageButton 为什么你不能使用这个

    theImageButton.setImageBitmap(cameraBitmap)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多