第三方框架,Custom Shape ImageView

先来张效果图

Shape Image View


使用步骤:

1、在Gradle 文件中添加以下代码,并重新构建一下工程

compile 'com.github.siyamed:android-shape-imageview:0.9.+@aar'

2、在布局文件中添加,下面添加 xmlns:app="http://schemas.android.com/apk/res-auto"

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="  //这里
    android:layout_width="match_parent"
    android:layout_height="124dp">

3、现在就可以使用了

    第一种:

Android Rounded Rectangle ImageView

<com.github.siyamed.shapeimageview.RoundedImageView    
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:src="@drawable/neo"
    app:siRadius="6dp"    //圆角半径
    app:siBorderWidth="6dp"  //边框宽度
    app:siBorderColor="@color/darkgray"//边框颜色
    app:siSquare="true"/> //是否设置宽度和高度的最小值,也就是使用自带的默认值

    第二种:

    Android Bubble ImageView

<com.github.siyamed.shapeimageview.BubbleImageView    
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:src="@drawable/neo"
    app:siArrowPosition="right" //箭头指向的地方
    app:siSquare="true"/>

    第三种:

    Android Circular ImageView

<com.github.siyamed.shapeimageview.CircularImageView    
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:src="@drawable/neo"
    app:siBorderWidth="6dp"
    app:siBorderColor="@color/darkgray"/>

    其他的:

Android Diamond ImageViewAndroid Pentagon ImageViewAndroid Hexagon ImageView

    DiamondImageView                PentagonImageView            HexagonImageView

Android Octogon ImageViewAndroid Start ImageViewAndroid Heart ImageView

    OctogonImageView                    StarImageView                        HeartImageView

//这里的只要将ClassName替换成上面的名字就可以使用了
<com.github.siyamed.shapeimageview.{ClassName}  
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="8dp"
    android:src="@drawable/neo"
    app:siBorderWidth="8dp"
    app:siBorderColor="@color/darkgray"/>


它还有一个强大的功能:可以根据自己的喜好来编写形状

    例:


<com.github.siyamed.shapeimageview.mask.PorterShapeImageView    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:siShape="@drawable/shape_rounded_rectangle"
    android:src="@drawable/neo"
    app:siSquare="true"/>

    //自定义形状

<shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android">
    <corners
        android:topLeftRadius="18dp"
        android:topRightRadius="18dp"
        android:bottomLeftRadius="18dp"
        android:bottomRightRadius="18dp" />
    <solid android:color="@color/black" />
</shape>

    

    源码网址:

    https://github.com/siyamed/android-shape-imageview

转载于:https://my.oschina.net/quTMD/blog/648167

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值