在drawable中新建一个shape_bg.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<!--圆角大小-->
<corners
android:radius="5dp"/>
<!--边框大小以及颜色-->
<stroke
android:width="1dp"
android:color="#ff0000"/>
<!--填充色-->
<solid android:color="#ffffff"/>
</shape>
引用为背景即可。
<ImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_gravity="center"
android:background="@drawable/shape_bg"
android:scaleType="fitXY"/>