Android:autoLink
在layout文件中的String.xml文件的内容是:
<stringname="webUrl">凤凰网:http://www.ifeng.com</string>
<stringname="email">小强的邮箱:sss@111.com</string>
<stringname="phoneNumber">电话号码:1333333335</string>
<stringname="mapUrl">620EighthAvenueNewYork,NY10018\n
</string>
<stringname="autoAll">
凤凰网:http://www.ifeng.com小强的邮箱:sss@111.com电话号码: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:
在java文件中新建一个MyBorderTextView文件:
在layout文件中新建一个border_tv文件:
实现的效果图为: