自定义view圆形头像

自定义view圆形头像

我已经将源码打包成依赖 朋友们可以直接导依赖直接使用

1.正常导入: implementation ‘com.github.LiHangKun:wuyuewuone:1’

implementation 'com.github.LiHangKun:wuyuewuone:1'

2.在最外层项目的build.gradle里面 maven { url ‘https://jitpack.io’ }

allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://jitpack.io' }  //这个是我们添加的必须加
    }
}

3.布局文件 这里面com.bw.wuyuewu.这个名字 不用管直接复制直接就可以用!!不需要任何修改

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <com.bw.wuyuewu.CircleImageView
        android:layout_width="50dp"
        android:id="@+id/img"
        android:layout_height="50dp" />

</LinearLayout>

4.类里面直接调用

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ImageView img = findViewById(R.id.img);
        String a="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1577442815232&di=49d50a07a4760c0ec89ddc3651e2b2e2&imgtype=0&src=http%3A%2F%2Fimg.pconline.com.cn%2Fimages%2Fupload%2Fupc%2Ftx%2Fwallpaper%2F1301%2F14%2Fc1%2F17389236_1358146562800.jpg";
        Glide.with(this).load(a).into(img);
        //Glide依赖是:implementation 'com.github.bumptech.glide:glide:4.9.0'
    }
}

如果没出来效果 检查自己是否在AndroidManifest.xm里面给了网络权限 步骤非常详细

<uses-permission android:name="android.permission.INTERNET"></uses-permission>

最后效果:
自定义view圆形头像_第1张图片

你可能感兴趣的:(自定义view)