TextView组件

TextView

AndroidautoLink

layout文件中的String.xml文件的内容是:

<stringname="webUrl">凤凰网:http://www.ifeng.com</string>

<stringname="email">小强的邮箱:[email protected]</string>

<stringname="phoneNumber">电话号码:1333333335</string>

<stringname="mapUrl">620EighthAvenueNewYork,NY10018\n

</string>

<stringname="autoAll">

凤凰网:http://www.ifeng.com小强的邮箱:[email protected]电话号码:1333333335

</string>

layout文件中建一个auto_link布局文件:

<TextView

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:autoLink="web"

android:text="@string/webUrl"/>

<TextView

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:autoLink="email"

android:text="@string/email"/>

<TextView

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:autoLink="phone"

android:text="@string/phoneNumber"/>

<TextView

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:autoLink="map"

android:text="@string/mapUrl"/>

<TextView

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:autoLink="all"

android:text="@string/autoAll"/>

<TextView

android:id="@+id/tvHtml"

android:layout_width="fill_parent"

android:layout_height="wrap_content"/>

显示效果为:

TextView组件

带边框的TextView

java文件中新建一个MyBorderTextView文件:

TextView组件

layout文件中新建一个border_tv文件:

TextView组件

实现的效果图为:

TextView组件