简体   繁体   中英

How can we add a border around text using HTML in textview?

How I can add borders around specifically selected text in a text view like this?

在此处输入图片说明

I have recelerview in the activity and the data showing in picture is get from server using API, the API send data wrap with HTML tags like

 "<div style=“border:2px solid red;padding: 5px;border-radius: 25px;”>the ground.</div>"

But the border tag is not supported by either Android nor iOS. I need to find a way to show border on both iOS and Android. If I need to communicate with a web team for a change I can do this, but any help will be appreciated.

Note: we cannot use Webview, because we need to perform some other operation on each text row.

Check the following line of code. I think this piece of code helpful for you:

 <div style="border:3px; border-style:solid; border-color:#000000; padding: 1em;">the ground.</div>

If you want get border in your text, set your html like this

 <div style="border:2px; border-style:solid; border-color: red; padding: 1em ; display: inline-block; border-radius: 25px;">the ground.</div>

But, i don't think that TextView can show css, in my experience i've using web view to do that.. Furthermore, my suggest if you don't want to use webview just set bold to specific word

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