在Android中原生定义Button就是矩形,我们可以通过简单样式,去改变本身死板的布局!
在drawable文件夹下写一个xml格式
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke android:color="@color/colorPrimary" android:width="1dp"/>
<corners android:radius="20dp"/>
</shape>
然后在layout的布局使用时,在background的属性下添加即可:
<Button
android:background="@drawable/flex_item_shape"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:id="@+id/t1"
android:text="当个人吧"
/>