=====【android里TextView加下划线的几种方式】=====
<string name="hello"><u>phone:0123456</u></string>
</resources>
如果是代码里:
TextView textView = (TextView)findViewById(R.id.tv_test);
textView.setText(Html.fromHtml("<u>"+"0123456"+"</u>"));
代码也可以这样:
tvTest.getPaint().setFlags(Paint. UNDERLINE_TEXT_FLAG ); //下划线
tvTest.getPaint().setAntiAlias(true);//抗锯齿
======【android 为TextView添加边框】======
通过shape来设置背景图片
首先一个textview_border.xml文件放在drawable文件夹里面
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<solid android:color="#ffffff" />
<stroke android:width="1dip" android:color="#4fa5d5"/>
</shape>
为要添加边框的TextView添加一个background
android:background="@drawable/textview_border"
如果是在资源文件里:
<resources><string name="hello"><u>phone:0123456</u></string>
</resources>
如果是代码里:
TextView textView = (TextView)findViewById(R.id.tv_test);
textView.setText(Html.fromHtml("<u>"+"0123456"+"</u>"));
代码也可以这样:
tvTest.getPaint().setFlags(Paint. UNDERLINE_TEXT_FLAG ); //下划线
tvTest.getPaint().setAntiAlias(true);//抗锯齿
======【android 为TextView添加边框】======
通过shape来设置背景图片
首先一个textview_border.xml文件放在drawable文件夹里面
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<solid android:color="#ffffff" />
<stroke android:width="1dip" android:color="#4fa5d5"/>
</shape>
为要添加边框的TextView添加一个background
android:background="@drawable/textview_border"