admin管理员组

文章数量:1333664

I have a textview in an Android application. I want to set the textview's value from HTML. For example, I get a value like this:

<span style="font-family:'Roboto-Regular'; font-size:13px; color:#383838 \">102,</span>
<span style="font-family:'Roboto-Regular'; font-size:11px; color:#383838 \">60 TL</span> 

and I want to set the textview's value using the fromhtml() method. The color tag is working perfectly, but the font-size tag is not working - I expect the text after the comma to be small, but the tag doesn't change the text size at all.

I have a textview in an Android application. I want to set the textview's value from HTML. For example, I get a value like this:

<span style="font-family:'Roboto-Regular'; font-size:13px; color:#383838 \">102,</span>
<span style="font-family:'Roboto-Regular'; font-size:11px; color:#383838 \">60 TL</span> 

and I want to set the textview's value using the fromhtml() method. The color tag is working perfectly, but the font-size tag is not working - I expect the text after the comma to be small, but the tag doesn't change the text size at all.

Share Improve this question edited Nov 21, 2024 at 8:00 Black cat 6,2975 gold badges29 silver badges61 bronze badges asked Nov 20, 2024 at 16:29 Mert DEMIRKIRANMert DEMIRKIRAN 4305 silver badges18 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Html.fromHtml() does not handle arbitrary HTML, let alone arbitrary CSS. While it does support color in a style attribute (at least on modern versions of Android), it does not support font-size or font-family. You will need to handle those yourself by other means.

本文标签: androidfont size is not working when using from htmlStack Overflow