小視頻源碼中自定義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>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章