图:
实现一个简单的图片边框
在布局文件中
设置
android:padding="3dp"
设置图片背景时
android:background="@drawable/image_frame"
代码
<ImageView
android:id="@+id/img"
android:layout_width="70dip"
android:layout_height="60dip"
android:scaleType="fitXY"
android:padding="3dp"
android:background="@drawable/image_frame"
/>
这是 image_frame.xml 放在 drawable 资源文件文件中
背景色
<solid android:color="#fff" />
最外层边框色
<stroke android:width="1dp" android:color="#dddddd" />
image_frame.xml 代码
<?xml version="1.0" encoding="UTF-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="#fff" /> <stroke android:width="1dp" android:color="#dddddd" /> </shape>