使用CircleImageView将图片圆形化

       CircleImageView是一个用于将图片圆形化的控件,它的用法很简单,基本和ImageView是完全一样的。几行代码就可以实现。
       我们先用最直观的方式来看一下它能实现的效果:
使用CircleImageView将图片圆形化_第1张图片
第一步:
在app/build.gradle中添加依赖:
dependencies {
compile fileTree(include: [’*.jar’], dir: ‘libs’)
androidTestCompile(‘com.android.support.test.espresso:espresso-core:2.2.2’, {
exclude group: ‘com.android.support’, module: ‘support-annotations’
})
pile ‘com.squareup.okhttp3:okhttp:3.4.1’
compile ‘com.google.code.gson:gson:2.7’
testCompile ‘junit:junit:4.12’
compile’de.hdodenhof:circleimageview:2.1.0’

}
第二步:
说明:你可以指定一张图片作为头像
下面就是你的布局,代码如下:
                android:id="@+id/icon_image"
        android:layout_width=“100dp”
        android:layout_height=“100dp”
       android:src="@drawable/yonghu1"
        android:layout_centerInParent=“true”
       android:clickable=“true”/>

剩下部分就是你们自己动手的部分了。

你可能感兴趣的:(Android篇)