前言
这里定义view实践以自定义Button的圆角实现为例
验证
创建自定义文件


添加布局属性

在layout中进行引用

具体效果如图

部分代码:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#ff0000"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content" />
<corners android:radius="5dp"
android:layout_width = "match_parent"
android:layout_height = "wrap_content" />
android:bottom="10dp"
android:left="10dp"
android:right="10dp"
android:top="10dp"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content" />
</shape>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_width="200dp"
android:layout_height="45dp"
android:layout_marginTop="10dp"
android:layout_below="@id/rg"
android:id="@+id/loginBtn"
android:text="登录"
android:background="@drawable/shape"
android:textSize="19sp"
android:textColor="#ffffff" />
</LinearLayout>
网友评论