zoukankan      html  css  js  c++  java
  • 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"


     

  • 相关阅读:
    Java 浮点数精度丢失
    旧梦。
    luogu6584 重拳出击
    luogu1758 [NOI2009]管道取珠
    luogu4298 [CTSC2008]祭祀
    bzoj3569 DZY Loves Chinese II
    AGC006C Rabbit Exercise
    bzoj1115 [POI2009]石子游戏Kam
    luogu5675 [GZOI2017]取石子游戏
    bzoj3143 [HNOI2013]游走
  • 原文地址:https://www.cnblogs.com/wgwyanfs/p/6898549.html
Copyright © 2011-2022 走看看