简体   繁体   中英

Android Spanned imageView

I've created a Spanned object that displays an image along with some text. Is it possible to get that imageView object so I could set it's background?

There is no ImageView object, so you cannot get it.

If you have an ImageSpan -- either that you added yourself directly or via something like an <img> tag in HTML you parsed with Html.fromHtml() -- you can get at the Drawable for the image. However, that is directly rendered to the canvas, not by way of an ImageView widget.

You can wrap the ImageSpan in a BackgroundColorSpan . Or, make sure that your image has the proper background already (eg, use a LayerListDrawable ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM