android textView 加入连接方式:

1:使用android:autoLink="all" 只需在textview中加入这个属性 在里面写的文字中包含网址、电话、email的会自动加入连接地址。

如:
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text1" android:layout_width="match_parent"
android:layout_height="match_parent" android:autoLink="all"
android:text="@string/link_text_auto" />
2:uses a string resource containing explicit <a> tags to specify
links.

如: <string name="link_text_manual"><b>text2:</b> This is some other
text, with a <a href="http://www.google.com">link</a> specified
via an &lt;a&gt; tag. Use a \"tel:\" URL
to <a href="tel:4155551212">dial a phone number</a>.
</string>
别忘了
TextView t2 = (TextView) findViewById(R.id.text2);
t2.setMovementMethod(LinkMovementMethod.getInstance());

3: builds the text in the Java code using HTML

TextView t3 = (TextView) findViewById(R.id.text3);
t3.setText(Html.fromHtml("<b>text3:</b> Text with a "
+ "<a href=\"http://www.google.com\">link</a> "
+ "created in the Java source code using HTML."));
t3.setMovementMethod(LinkMovementMethod.getInstance());


4:字符串截取方法
SpannableString ss = new SpannableString("text4: Click here to dial the phone.");

ss.setSpan(new StyleSpan(Typeface.BOLD), 0, 6, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
ss.setSpan(new URLSpan("tel:4155551212"), 13, 17, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

TextView t4 = (TextView) findViewById(R.id.text4);
t4.setText(ss);
t4.setMovementMethod(LinkMovementMethod.getInstance());








Android中我们为了实现文本的滚动可以在ScrollView中嵌入一个TextView,其实TextView自己也可以实现多行滚动的,毕竟ScrollView必须只能有一个直接的子类布局。只要在layout中简单设置几个属性就可以轻松实现

<TextView
android:id="@+id/tvCWJ"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical" <!--垂直滚动条 -->
android:singleLine="false" <!--实现多行 -->
android:maxLines="15" <!--最多不超过15行 -->
android:textColor="#FF0000"
/>

当然我们为了让TextView动起来,还需要用到TextView的setMovementMethod方法设置一个滚动实例,代码如下

TextView tvAndroid123 = (TextView)findViewById(R.id.tvCWJ);
tvAndroid123.setMovementMethod(ScrollingMovementMethod.getInstance()); // Android开发网提示相关的可以查看SDK中android.text.method分支了解更多

ad_link = (TextView) findViewById(R.id.ad_link);
ad_link.setText(Html.fromHtml("<a href="\" mce_href="\"""+mURL.getLink()+"\">"+Html.fromHtml(mURL.getLabel()+"</a>")));
ad_link.setMovementMethod(LinkMovementMethod.getInstance());

更多相关文章

  1. 实现底部导航栏中间凸起
  2. EditView某些属性说明
  3. Android使用FFmpeg(二)--Android(安卓)Studio配置ffmpeg
  4. android 实现 搜索保存历史记录功能
  5. Android启动画面实现
  6. Android启动画面实现
  7. Android(安卓)OpenGL ES学习笔记之实现OpenGL ES接口
  8. Android(安卓)recyclerview实现查看更多/收起功能
  9. Android实现微信底部导航条

随机推荐

  1. Android开发AsyncTask异步处理任务使用方
  2. Android(安卓)跨进程传输大图片
  3. Android实现多个跑马灯效果,多个文本框Tex
  4. Android线程的一些问题
  5. 在Eclipse中加入Android源码
  6. 【腾讯开源】Android性能测试工具APT使用
  7. android用贝塞尔曲线完成viewpager轮播指
  8. Git | 上传 Android(安卓)项目到 GitHub
  9. Android(安卓)- 分享内容 - 给其他APP发
  10. Android(安卓)使用 Usb Accessory 模式与