Reference 1 2 3 4
One, custom view inherit ImageView file
New Attr.xml Copy code under Value folder
1<?xml version= "1.0" encoding= "Utf-8"?>2<resources>3<declare-styleable name= "Shapedimageview" >4<attr name= "Shape_mode" format= "enum" >5<enumName= "Round_rect" value= "1"/>6<enumName= "Circle" value= "2"/>7</attr>8<attr name= "Round_radius" format= "Dimension"/>9<attr name= "Stroke_width" format= "Dimension"/>Ten<attr name= "Stroke_color" format= "Color|reference"/> One</declare-styleable> A</resources>
attr
Copy the Shapedimageview.java file to the View folder
Add xmlns:app= "Http://schemas.android.com/apk/res-auto" under the layout file to create a
Round app:shape_mode= "Circle" app:stroke_color border color app:stroke_width border size
1 <Com.xxxx.view.ShapedImageView2 android:id= "@+id/iv_circle5"3 android: Layout_width= "100DP"4 android:layout_height= "100DP"5 android:scaletype= "Centercrop" 6 App:shape_mode= "Circle"7 />
Corner Rectangle app:shape_mode= "Round_rect" App:round_radius rectangle radian app:stroke_color Border color app:stroke_width border size
1 <Com.xxxx.view.ShapedImageView 2 android:id= "@+id/iv_circle6" 3 android: Layout_width= "100DP" 4 android:layout_height= "100DP" 5 android:scaletype= "Centercrop" 6 App:shape_mode= "Round_rect" 7 app:round_radius= "20DP" 8 app:stroke_width= "5DP" 9 App:stroke_color= "#1E90FF"ten />
It is worth mentioning that android:scaletype= "Centercrop" if not set to get the network picture will have a problem with the local picture no problem but it's best to set
Universalimageloader Glide can load normally
Second, Glide bitmaptransformation
Round Glidecircletransform
Angular Rectangle Glideroundtransform
Add these 2 files to the project folder
And then use it in glide.
Glide.with (this). Load (IMAGEURL1). Transform (new glidecircletransform (context)). into ( IMAGEVIEW1); Glide.with (this). Load (IMAGEURL2). Transform (new glideroundtransform (context)). into ( IMAGEVIEW2); Glide.with (this). Load (IMAGEURL2). Transform (new glideroundtransform (context,10)). into ( IMAGEVIEW3);
But it has no border effect and can only be glide.
Android round picture