只需要在你的drawable中建立一个名bg-border的资源文件即可
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#EEEEEE" />
<stroke android:width="3dp" android:color="#EEEEEE" />
<corners android:radius="0dp" />
<padding android:left="0dp" android:top="0dp"
android:right="0dp" android:bottom="0dp" />
</shape>
在Imageview定义页面上使用代码:
<ImageView
android:id="@+id/img"
android:background="@drawable/bg_border"
android:src="@mipmap/ic_launcher"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
只需在drawable资源文件创建一个名为bg-border的shape,设置边框宽度、颜色和角部半径,然后在ImageView中应用此背景,即可为ImageView添加边框。
2999

被折叠的 条评论
为什么被折叠?



