- import android.app.Activity;
- import android.graphics.Color;
- import android.graphics.Typeface;
- import android.graphics.drawable.Drawable;
- import android.os.Bundle;
- import android.text.Spannable;
- import android.text.SpannableString;
- import android.text.Spanned;
- import android.text.method.LinkMovementMethod;
- import android.text.style.ForegroundColorSpan;
- import android.text.style.ImageSpan;
- import android.text.style.StrikethroughSpan;
- import android.text.style.StyleSpan;
- import android.text.style.URLSpan;
- import android.text.style.UnderlineSpan;
- import android.widget.TextView;
- public class AndroidAct extends Activity {
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super .onCreate(savedInstanceState);
- TextView txtInfo = new TextView( this );
- SpannableString ss = new SpannableString( "要输入的内容!" );
- ss.setSpan(new ForegroundColorSpan(Color.RED), 0 , 2 ,
- Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
- ss.setSpan(new URLSpan( "tel:4155551212" ), 0 , 5 ,
- Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
- ss.setSpan(new StyleSpan(Typeface.BOLD_ITALIC), 5 , 7 ,
- Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
- ss.setSpan(new StrikethroughSpan(), 0 , ss.length() ,
- Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
- ss.setSpan(new UnderlineSpan(), 10 , 16 ,
- Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
- ss.setSpan(new ForegroundColorSpan(Color.GREEN), 10 , 15 ,
- Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
- Drawable d = getResources().getDrawable(R.drawable.icon);
- d.setBounds(0 , 0 , d.getIntrinsicWidth(), d.getIntrinsicHeight());
- ImageSpan span = new ImageSpan(d, ImageSpan.ALIGN_BASELINE);
- ss.setSpan(span, 18 , 19 , Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
- txtInfo.setText(ss);
- txtInfo.setMovementMethod(LinkMovementMethod.getInstance());
- setContentView(txtInfo);
- }
- }
-
<a href="..."> 定义链接内容
-
<b>
定义粗体文字 b 是blod的缩写 -
<big>
定义大字体的文字 -
<blockquote>
引用块标签 -
<br>
定义换行 -
<cite>
表示引用的URI -
<dfn>
定义标签 dfn 是defining instance的缩写 -
<div align="...">
-
<em>
强调标签 em 是emphasis的缩写 -
<font size="..." color="..." face="...">
-
<h1>
-
<h2>
-
<h3>
-
<h4>
-
<h5>
-
<h6>
-
<i>
定义斜体文字 -
<img src="...">
-
<p>
段落标签,里面可以加入文字,列表,表格等 -
<small>
定义小字体的文字 -
<strike>
定义删除线样式的文字 不符合标准网页设计的理念,不赞成使用. strike是strikethrough的缩写 -
<strong>
重点强调标签 -
<sub>
下标标签 sub 是subscript的缩写 -
<sup>
上标标签 sup 是superscript的缩写 -
<tt>
定义monospaced字体的文字 不赞成使用. 此标签对中文没意义 tt是teletype or monospaced text style的意思 -
<u>
定义带有下划线的文字 u是underlined text style的意思