android点击邮箱链接跳转发送

strings.xml文件中的内容:

<resources>
    <string name="app_name">My Application</string>
    <string name="author">作者:u010746364</string>
    <string name="email">邮箱:move_life@163.com</string>
    <string name="blog">博客:http://blog.csdn.net/u010746364</string>
</resources>

xml文件的内容:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white"
    android:orientation="vertical">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:autoLink="web"
        android:textColorHighlight="@color/white"
        android:text="@string/author"
        android:textSize="16sp" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColorHighlight="@color/white"
        android:layout_marginTop="10dp"
        android:autoLink="email"
        android:text="@string/email"
        android:textSize="16sp" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:textColorHighlight="@color/white"
        android:autoLink="web"
        android:text="@string/blog"
        android:textSize="16sp" />
</LinearLayout>


比如这里在邮箱相关的TextView加上android:autoLink="email"属性,网页相关的TextView加上android:autoLink="web"属性。

当点击相关的内容的时候,自动跳转到系统的邮箱发送界面和浏览器界面。当然也可以用其他的方式实现这样子的效果。


还要注意设置这里面的android:textColorHighlight属性,设置之后,点击TextView之后的背景颜色。设置好就可以实现点击之后背景颜色不变化。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值