GettingSignals

[Android]TextView に使用できるHTMLタグ一覧

2012年11月20日
Posted by hina

TextView にHTMLタグありの文字列をセットすると、
リンクや文字色などを設定することができたりします。

String html_source;
textView.setText(Html.fromHtml(html_source);

しかし、
すべてのHTMLタグが使える訳ではないです。

使用できるタグはここ参照。
http://commonsware.com/blog/Android/2010/05/26/html-tags-supported-by-textview.html

<a href=”…”>
<b>
<big>
<blockquote>
<br>
<cite>
<dfn>
<div align=”…”>
<em>
<font size=”…” color=”…” face=”…”>
<h1>
<h2>
<h3>
<h4>
<h5>
<h6>
<i>
<img src=”…”>
<p>
<small>
<strike>
<strong>
<sub>
<sup>
<tt>
<u>

<a>タグでリンク張り、ブラウザ起動させたい場合は、以下の設定も必要です。

MovementMethod movementmethod = LinkMovementMethod.getInstance();
textView.setMovementMethod(movementmethod);

Share

Comments are currently closed.

Follow

カレンダー

2024年4月
1234567
891011121314
15161718192021
22232425262728
2930