textview加矩形边框和圆角边框

代码实现:

Step 1:编写 矩形边框 的Drawable:

xml version="1.0" encoding="utf-8"?>
 xmlns:android="http://schemas.android.com/apk/res/android" >

    
     android:width="2px" android:color="#000000"/>
    
    
        android:angle="270"
        android:endColor="#C0C0C0"
        android:startColor="#FCD209" />
    
    
        android:left="5dp"
        android:top="5dp"
        android:right="5dp"
        android:bottom="5dp"/>

 

Step 2:编写 圆角矩形边框 的Drawable:

xml version="1.0" encoding="utf-8"?>
 xmlns:android="http://schemas.android.com/apk/res/android">

    
     android:color="#87CEEB" />

    
    
        android:width="2px"
        android:color="#000000" />
    
    
        android:bottomLeftRadius="10px"
        android:bottomRightRadius="10px"
        android:topLeftRadius="10px"
        android:topRightRadius="10px" />
    
    
        android:bottom="5dp"
        android:left="5dp"
        android:right="5dp"
        android:top="5dp" />
        

你可能感兴趣的:(代码片段)