Android實(shí)現(xiàn)用戶(hù)圓形頭像和模糊背景
本文實(shí)例為大家分享了Android實(shí)現(xiàn)用戶(hù)圓形頭像和模糊背景的具體代碼,供大家參考,具體內(nèi)容如下
1、效果展示
2、在build.gradle(Module)中的dependencies里面加入下面依賴(lài)
注意:glide依賴(lài)的版本
//圖片加載框架 implementation 'jp.wasabeef:glide-transformations:2.0.2' //圖片模糊效果 compile 'com.github.bumptech.glide:glide:3.7.0' //圓形頭像 implementation 'de.hdodenhof:circleimageview:2.2.0'
3、布局實(shí)現(xiàn),activity_head.xml
<?xml version="1.0" encoding="utf-8"?> <FrameLayout 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="wrap_content" tools:context=".charttest.HeadActivity"> <ImageView android:id="@+id/mImage" android:layout_width="match_parent" android:layout_height="200dp" android:scaleType="centerCrop" /> <de.hdodenhof.circleimageview.CircleImageView android:id="@+id/civ_head" android:layout_width="70dp" android:layout_height="70dp" android:src="@drawable/head" android:layout_gravity="center" /> </FrameLayout>
4、核心類(lèi)實(shí)現(xiàn)HeadActivity.java
package com.example.crab_breeding.charttest; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.widget.ImageView; import com.bumptech.glide.Glide; import com.example.crab_breeding.R; import jp.wasabeef.glide.transformations.BlurTransformation; public class HeadActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_head); //獲取圓形頭像和背景的imageview實(shí)例 ImageView mImage=findViewById(R.id.mImage); ImageView civ_head=findViewById(R.id.civ_head); //背景模糊實(shí)現(xiàn) // 參數(shù)20 表示模糊背景圖片的放大參數(shù) 越大背景圖片越模糊 Glide.with(HeadActivity.this) .load(R.drawable.head) .bitmapTransform(new BlurTransformation(HeadActivity.this,20,2)) .into(mImage); //頭像圓形實(shí)現(xiàn) Glide.with(HeadActivity.this) .load(R.drawable.head) .into(civ_head); } }
5、完成
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- android10 隱藏SystemUI鎖屏下的多用戶(hù)圖標(biāo)的示例代碼
- Android 如何攔截用戶(hù)頻繁操作(點(diǎn)擊事件)
- Android實(shí)現(xiàn)簡(jiǎn)單用戶(hù)注冊(cè)案例
- Android啟動(dòng)頁(yè)用戶(hù)相關(guān)政策彈框的實(shí)現(xiàn)代碼
- 詳解Android Studio實(shí)現(xiàn)用戶(hù)登陸界面demo(xml實(shí)現(xiàn))
- android實(shí)現(xiàn)記住用戶(hù)名和密碼以及自動(dòng)登錄
- Android權(quán)限如何禁止以及友好提示用戶(hù)開(kāi)通必要權(quán)限詳解
- Android百度地圖定位、顯示用戶(hù)當(dāng)前位置
- Android模擬用戶(hù)點(diǎn)擊的實(shí)現(xiàn)方法
- Android EditText 監(jiān)聽(tīng)用戶(hù)輸入完成的實(shí)例
- Android 用戶(hù)Session管理的設(shè)計(jì)方案
- Android基于A(yíng)larmManager實(shí)現(xiàn)用戶(hù)在線(xiàn)心跳功能示例
- Android 多用戶(hù)詳情
相關(guān)文章
Android開(kāi)發(fā)筆記之:Dialog的使用詳解
本篇文章是對(duì)Android中Dialog的使用進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-05-05android實(shí)現(xiàn)靜默安裝與卸載的方法
這篇文章主要介紹了android實(shí)現(xiàn)靜默安裝與卸載的方法,涉及Android權(quán)限與命令行操作的相關(guān)技巧,需要的朋友可以參考下2015-05-05Android自定義ScrollView實(shí)現(xiàn)放大回彈效果
這篇文章主要為大家詳細(xì)介紹了Android自定義ScrollView實(shí)現(xiàn)放大回彈效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-05-05Android實(shí)戰(zhàn)打飛機(jī)游戲之菜單頁(yè)面設(shè)計(jì)(1)
這篇文章主要為大家詳細(xì)介紹了Android實(shí)戰(zhàn)打飛機(jī)游戲之菜單頁(yè)面設(shè)計(jì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-07-07Android倒計(jì)時(shí)功能的實(shí)現(xiàn)代碼
這篇文章主要介紹了Android倒計(jì)時(shí)功能的實(shí)現(xiàn)代碼,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-12-12android實(shí)現(xiàn)加載動(dòng)畫(huà)對(duì)話(huà)框
這篇文章主要為大家詳細(xì)介紹了android實(shí)現(xiàn)加載動(dòng)畫(huà)對(duì)話(huà)框,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-10-10Android實(shí)現(xiàn)保存圖片到本地并在相冊(cè)中顯示
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)保存圖片到本地并在相冊(cè)中顯示的相關(guān)代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-03-03Android仿京東淘寶自動(dòng)無(wú)限循環(huán)輪播控件思路詳解
在A(yíng)pp的開(kāi)發(fā)中,很多的時(shí)候都需要實(shí)現(xiàn)類(lèi)似京東淘寶一樣的自動(dòng)無(wú)限輪播的廣告欄,這里小編寫(xiě)了一個(gè),分享到腳本之家平臺(tái)供大家參考2017-04-04