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" />
本文介绍如何通过XML自定义Android中TextView的样式,包括背景颜色、边框宽度及颜色、圆角等属性设置方法。
1万+

被折叠的 条评论
为什么被折叠?



