好久没写布局,突然之间需要写一个,为了美化要进行对四边的圆角处理,自定义一个圆角矩形不值得,于是翻了翻之前的代码,操作一波。
1.在Drawable文件夹下创建一个文件:
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <!-- 填充色--> <solid android:color="@color/colorHazeBlue"/> <!-- 圆角弧度--> <corners android:radius="@dimen/text_50"/> <!-- 四周内边距--> <padding android:left="20px" android:right="20px" android:bottom="15px" android:top="15px"/> <!-- 边框颜色--> <stroke android:color="@color/colorWhite"/> </shape>
2.用法:在需要使用的控件设置Background即可
<TextView android:id="@+id/tv_createOperta" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="生成脚本" android:textSize="@dimen/text_36" android:textColor="@color/colorTextWhite" android:background="@drawable/add_shape" android:layout_centerHorizontal="true" />