Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在android中向textview添加位图图像_Android - Fatal编程技术网

如何在android中向textview添加位图图像

如何在android中向textview添加位图图像,android,Android,我有图像的位图。我想将该图像放在文本视图中。我怎样才能在安卓系统中做到这一点 我已经选中了setCompoundDrawablesWithIntrinsicBounds(),但我只能在其中添加可绘制的资源。您可以设置为textview的背景,您可以在textview背景中将其添加到图像中。如果你想在textview背景中添加位图,你必须在drawble位图中进行转换。下面的代码介绍如何使用位图设置backroud TextView txt=(TextView)findViewById(R.id.

我有图像的位图。我想将该图像放在文本视图中。我怎样才能在安卓系统中做到这一点


我已经选中了
setCompoundDrawablesWithIntrinsicBounds()
,但我只能在其中添加可绘制的资源。

您可以设置为textview的背景,您可以在textview背景中将其添加到图像中。如果你想在textview背景中添加位图,你必须在drawble位图中进行转换。下面的代码介绍如何使用位图设置backroud

TextView txt=(TextView)findViewById(R.id.textview);
txt.setBackground(new BitmapDrawable(getResources(), bitmap));

我不希望它作为背景图像..它应该是一个图像而不是文本它有什么区别吗<代码>textView.setText(“”)将没有前景。您应该使用
图像视图
,或者在
文本视图
中设置图像有什么特殊情况吗?