HTML în TextView

Androidul permite utilizarea unor tag-uri HTML în TextView care permit customizarea designului.

magda_badita_html

TextView htmlTextView = (TextView)findViewById(R.id.html_text);
String htmlText = "<b>Text bold</b>";
htmlTextView.setText(Html.fromHtml(htmlText));

Tag-uri suportate în String Resources:

  • <a> (supports attributes “href”)
  • <annotation>
  • <b>
  • <big>
  • <font> (supports attributes “height”, “size”, “fgcolor” and “bicolor”, as integers)
  • <i>
  • <li>
  • <marquee>
  • <small>
  • <strike>
  • <sub>
  • <sup>
  • <tt>
  • <u>

Tag-uri suportate pentru Html.fromHtml:

  • <a> (supports attribute “href”)
  • <b>
  • <big>
  • <blockquote>
  • <br>
  • <cite>
  • <dfn>
  • <div>
  • <em>
  • <font> (supports attributes “color” and “face”)
  • <i>
  • <img> (supports attribute “src”. Note: you have to include an ImageGetter to handle retrieving a Drawable for this tag)
  • <p>
  • <small>
  • <strong>
  • <sub>
  • <sup>
  • <tt>
  • <u>

Culori suportate:

  • aqua
  • black
  • blue
  • fuchsia
  • green
  • grey
  • lime
  • maroon
  • navy
  • olive
  • purple
  • red
  • silver
  • teal
  • white
  • yellow
Advertisements
HTML în TextView

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s