简体   繁体   English

使用HTML在TextView中的图像上方设置文本

[英]Set text above image in TextView using HTML

I have a list of Strings that I add to TextViews one by one. 我有一个字符串列表,我一一添加到TextViews中。 The text is html so I can add images within the text. 文本是html,因此我可以在文本内添加图像。 So my question is... How can I add an Image so that the text appears above it. 所以我的问题是...如何添加图像,以使文本显示在图像上方。 currently while using HTML.ImageGetter class text is added below the image, not above it: Here is my Html text to be shown: 当前在使用HTML.ImageGetter类文本时,将其添加到图像下方,而不是图像上方:这是要显示的HTML文本:

myText += "<img src='titles.png'><span> text to be above image </span>";

Please try following code as example(Html text is changed): 请尝试以下代码作为示例(HTML文本已更改):

myText += "<div style='position: relative;width: 100%;'> <img src='titles.png'><span style='position: absolute;top: 100px;left: 0;width: 100%;'> text to be above image </span></div>";

I referred http://css-tricks.com/text-blocks-over-image/ for checking for css properties. 我参考了http://css-tricks.com/text-blocks-over-image/检查CSS属性。 Hope this is helpful for you. 希望这对您有帮助。

Thanks & Regards, 感谢和问候,

Chanchal 尚沙尔

you can add a simple alt="texthover" to the anchor tag and it will display the text in the alt in most browsers. 您可以在锚标记中添加一个简单的alt =“ texthover”,它将在大多数浏览器中的alt中显示文本。

But that is not as good as creating an a.hover class that would display text or a div that has text. 但这不如创建一个显示文本或具有文本的div的a.hover类好。

Does that help? 有帮助吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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