android - Applying dimensions from dimens.xml to text formatted with Html.fromHtml -
i have code setting text of textview:
textview txt = new textview(this); txt.settext(html.fromhtml("<b>" + m.gettitle() + "</b>" + "<br />" + "<small>" + m.gettext() + "</small>" + "<br />");
the <small>
mark working, i'd set text size according dimensions defined in dimens.xml file, use other text in application. adding textview through xml layout not option since don't know how many textviews i'll adding.
dimensions in dimens.xml file set <dimen name="text_size_320dp_small">16sp</dimen>
.
how can apply these dimensions text formatted html.fromhtml
?
thanks lot.
you can't directly, small tag creates relativesizespan proportion of .8f
, hardcoded implementation of html.fromhtml
.
leaves 2 options can see, set text size 20sp (which make small work out 16sp). not ideal.
the other option use custom tag <mysmall>
replacing occurrences of <small>
, </small>
<mysmall>
& </mysmall>
. , call fromhtml (string source, html.imagegetter imagegetter, html.taghandler taghandler) taghandler
integrates absolutesizespan output editable
.
Comments
Post a Comment