以下内容摘录自:https://blog.youkuaiyun.com/way_ping_li/article/details/8469975
采用设置xml背景的方式实现。
背景定义xml: bg_border.xml
<?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/iv_thumbnail"
android:layout_height="63dp"
android:layout_width="63dp"
android:background="@drawable/bg_border"
android:padding="3dp"
/>
这篇博客介绍了如何通过创建一个XML形状资源文件来为ImageView设置边框。在bg_border.xml中定义了一个带有填充颜色和描边宽度的矩形,并在布局文件中应用到ImageView,同时设置了内边距以实现边框效果。
279

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



