imageview设置边框

来源:互联网 发布:海岛奇兵22级兵种数据 编辑:程序博客网 时间:2024/05/19 00:36

对于imageview设置边框有几种方法,其中一种可以直接设置带边框的图片,但是一般做项目的时候获得都是服务器传过来的图片,此时将图片下载下来再设置边框,可以当然可以,但是维护太麻烦,此时可以用一种很简单的方式:自定义一个bg_border.xml:

<?xml version="1.0" encoding="UTF-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android">    <corners android:radius="1.0px" />    <stroke android:color="#ff0400" android:width="2px"/>    <solid android:color="@android:color/white" /></shape>
随后设置就可以了:

<ImageView    android:id="@+id/iv_right_top"    android:layout_width="80dp"    android:layout_height="68dp"    android:layout_marginLeft="5dp"    android:layout_marginTop="10dp"    android:padding="1dp"    android:scaleType="centerInside"     android:background="@drawable/bg_border"/>

原创粉丝点击