Android 圆形、圆角图片ImageView

圆形、圆角图片ImageView

当时做这个功能的时候也是从网上找的、比较好用的demo

作者以及详细解释请见:Android BitmapShader 实战 实现圆形、圆角图片

在这里主要讲一下如何使用

1、把RoundImageView导入包下

2、在xml中配置

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:yqy="http://schemas.android.com/apk/res/com.yqy.yqy_roundimg"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity" >

    <com.yqy.yqy_roundimg.RoundImageView
        android:id="@+id/imageView1"
        android:layout_width="70dp"
        android:layout_height="70dp"
        android:layout_marginLeft="48dp"
        android:layout_marginTop="46dp"
        android:src="@drawable/logo" />

    <com.yqy.yqy_roundimg.RoundImageView
        android:layout_width="70dp"
        android:layout_height="70dp"
        android:layout_marginLeft="48dp"
        android:layout_marginTop="46dp"
        android:src="@drawable/logo"
        yqy:borderRadius="15dp"
        yqy:type="round" />

    <com.yqy.yqy_roundimg.RoundImageView
        android:layout_width="70dp"
        android:layout_height="70dp"
        android:layout_marginLeft="48dp"
        android:layout_marginTop="46dp"
        android:src="@drawable/logo"
        yqy:borderRadius="10dp"
        yqy:type="round" />

    <com.yqy.yqy_roundimg.RoundImageView
        android:layout_width="70dp"
        android:layout_height="70dp"
        android:layout_marginLeft="48dp"
        android:layout_marginTop="46dp"
        android:src="@drawable/logo"
        yqy:borderRadius="5dp"
        yqy:type="round" />

</LinearLayout>


默认就是圆形图片

如果想要设置圆角矩形

看上面代码的头部有如下代码

xmlns:yqy=<a target=_blank href="http://schemas.android.com/apk/res/com.yqy.yqy_roundimg">http://schemas.android.com/apk/res/com.yqy.yqy_roundimg</a>

设置一个属性yqy为自定义,值最后为包名

控件代码中设置如下属性

        yqy:borderRadius="15dp"
        yqy:type="round" 

borderRadius 为圆角半径

type  为round  圆角矩形
yqy:borderRadius="15dp"yqy:borderRadius="15dp"


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Android翻山之路

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值