通过资源文件 实现 textview 添加边框
如图:
下面附上资源文件代码:
四周边框
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 四周边框 -->
<!-- 边框颜色值 -->
<item>
<shape>
<solid android:color="#f00" />
</shape>
</item>
<item
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp">
<!--边框里面背景颜色 白色-->
<shape>
<solid android:color="#ffffff" />
</shape>
</item>
</layer-list>
左右边框
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 边框颜色值 -->
<item>
<shape>
<solid android:color="#f00" />
</shape>
</item>
<item
android:left="1dp"
android:right="1dp">
<!--边框里面背景颜色 白色-->
<shape>
<solid android:color="#ffffff" />
</shape>
</item>
</layer-list>
上下边框
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 边框颜色值 -->
<item>
<shape>
<solid android:color="#f00" />
</shape>
</item>
<item
android:bottom="1dp"
android:top="1dp">
<!--边框里面背景颜色 白色-->
<shape>
<solid android:color="#ffffff" />
</shape>
</item>
</layer-list>
下边框
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 边框颜色值 -->
<item>
<shape>
<solid android:color="#f00" />
</shape>
</item>
<item android:bottom="1dp">
<!--边框里面背景颜色 白色-->
<shape>
<solid android:color="#ffffff" />
</shape>
</item>
</layer-list>