Set Bitmap as background of Text View - Android

后端 未结 1 1415
星月不相逢
星月不相逢 2020-12-20 22:52

I have a bitmap in memory at run-time. I want to set the background of a text view to this bitmap. I am not able to find any standard procedure for that (not a hacky one). I

相关标签:
1条回答
  • 2020-12-20 23:25

    According to the API docs, setBackgroundResource expects an int.

    If you definitely need a bitmap, you can use setBackgroundDrawable instead and wrap your bitmap in a BitmapDrawable. example

    textureView.setBackground(new BitmapDrawable(getResources(), bitmap));
    
    0 讨论(0)
提交回复
热议问题