Android 自定义 TextView 的样式,改变背景颜色,边框粗细和颜色,角的弧度等
在 res/drawable 文件夹下新建一个 dd.xml 文件,建一个 shap,在里面添加需要改变的内容
- <shape xmlns:android="http://schemas.android.com/apk/res/android">
- <solid android:color="#ef0909"></solid>//设置背景色
- <stroke android:width="1px" android:color="#06ef21"></stroke>//设置边框属性
- </shap
在布局文件中有控件引用刚才定义的 xml 文件
- <TextView
- android:id="@+id/te"
- android:layout_width="300px"
- android:layout_height="100px"
- android:layout_marginTop="50px"
- android:background="@drawable/dd"
- />
来源: http://www.bubuko.com/infodetail-2451582.html