码迷,mamicode.com
首页 > 移动开发 > 详细

Android 圆形、圆角图片ImageView

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

标签: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"


 

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

Android 圆形、圆角图片ImageView

标签:android   imageview   圆形图片   圆角图片   图片   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!