首页 > 移动平台 > 详细

Android 圆形、圆角图片ImageView

时间:2015-08-21 13:46:27      阅读:297      评论:0      收藏:0      [点我收藏+]

圆形、圆角图片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"


 

版权声明:本文为博主原创文章,未经博主允许不得转载。

Android 圆形、圆角图片ImageView

原文:http://blog.csdn.net/u012885461/article/details/47831417

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!