Android图片圆角转换 RoundedImageView开源项目 小记,美团Android面试

1: 去github上下载 工程


https://github.com/vinc3m1/RoundedImageView

2: 导入工程


3  在布局中使用它


<com.makeramen.rounded.RoundedImageView

android:id="@+id/imageView1"

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_alignParentTop=“true”

android:layout_alignParentBottom=“true”

android:layout_alignParentRight=“true”

android:layout_alignParentLeft=“true”

android:padding="
10dip"

android:src="@drawable/photo1"

android:scaleType=“center”

makeramen:corner_radius=“30dip”

makeramen:border_width=“2dip”

makeramen:border_color="#333333" />

属性的意义:

makeramen:border_width=“2dip”   表示图片的边框宽度为2个dp

makeramen:  corner_radius表示为  图片转圆角的弧度

修改    makeramen:corner_radius=“100dip”

当  corner_radius 设置为100dp 的时候   会呈现为圆形 .

(    注:  com.makeramen.rounded.RoundedImageView  控件的宽和高需要相等   )

修改了example中的    rounded_item.xml

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout

xmlns:android=“http://schemas.android.com/apk/res/android”

xmlns:makeramen=“http://schemas.android.com/apk/res/com.makeramen.rounded.example”

android:layout_width=“match_parent”

android:layout_height=“200dip”>

<com.makeramen.rounded.RoundedImageView

android:id="@+id/imageView1"

android:layout_width=“200dp”

android:layout_height=“200dp”

android:padding=“10dip”

android:src="@d

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值