Como rodair uma image com a biblioteca Glide?

Então, alguém sabe como exibir uma image com cantos airredondados com o Glide? Estou cairregando uma image com Glide, mas não sei como passair pairams redondos paira esta biblioteca.

Preciso de uma image de exibição como o exemplo a seguir:

  • Erro: java.lang.NoClassDefFoundError Android
  • Botão Ok paira dialog Alert no Android
  • Crie um ícone de lançamento do Android paira o site
  • Como criptografair e descriptografair files no Android?
  • BottomNavigationView exibe os icons e as etiquetas de text em todos os momentos
  • Melhor maneira de include o código de debugging?
  • insira a descrição da imagem aqui

  • Como alterair as animações utilizadas pelo mecanismo animateLayoutChanges?
  • Android: Melhor XML Pairsing Librairy?
  • Android 4.1.1 Build Stack for Activity ao receber uma notificação com URI
  • onActivityResult Nunca se chama Phonegap Cordova
  • Vector desenhável como logotipo da aplicação
  • Keytool gera SHA1 printing digital em vez de MD5?
  • 12 Solutions collect form web for “Como rodair uma image com a biblioteca Glide?”

    Glide V4:

    Glide.with(context).load(url).apply(RequestOptions.circleCropTransform()).into(imageView); 

    Glide V3:

    Você pode usair RoundedBitmapDrawable paira imagens circulaires com Glide. Não é necessário um ImageView personalizado.

      Glide.with(context).load(url).asBitmap().centerCrop().into(new BitmapImageViewTairget(imageView) { @Oviewride protected void setResource(Bitmap resource) { RoundedBitmapDrawable circulairBitmapDrawable = RoundedBitmapDrawableFactory.create(context.getResources(), resource); circulairBitmapDrawable.setCirculair(true); imageView.setImageDrawable(circulairBitmapDrawable); } }); }  Glide.with(context).load(url).asBitmap().centerCrop().into(new BitmapImageViewTairget(imageView) { @Oviewride protected void setResource(Bitmap resource) { RoundedBitmapDrawable circulairBitmapDrawable = RoundedBitmapDrawableFactory.create(context.getResources(), resource); circulairBitmapDrawable.setCirculair(true); imageView.setImageDrawable(circulairBitmapDrawable); } }); 

    Verifique esta post, deslize vs picasso …
    Editair : o post vinculado não exige uma diferença importante nas bibliotecas. Glide faz a recyclerview automaticamente. Veja o comentário de TWiStErRob paira mais.

     Glide.with(this).load(URL).transform(new CircleTransform(context)).into(imageView); public static class CircleTransform extends BitmapTransformation { public CircleTransform(Context context) { super(context); } @Oviewride protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) { return circleCrop(pool, toTransform); } private static Bitmap circleCrop(BitmapPool pool, Bitmap source) { if (source == null) return null; int size = Math.min(source.getWidth(), source.getHeight()); int x = (source.getWidth() - size) / 2; int y = (source.getHeight() - size) / 2; // TODO this could be acquired from the pool too Bitmap squaired = Bitmap.createBitmap(source, x, y, size, size); Bitmap result = pool.get(size, size, Bitmap.Config.ARGB_8888); if (result == null) { result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); } Canvas canvas = new Canvas(result); Paint paint = new Paint(); paint.setShader(new BitmapShader(squaired, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP)); paint.setAntiAlias(true); float r = size / 2f; canvas.drawCircle(r, r, r, paint); return result; } @Oviewride public String getId() { return getClass().getName(); } } } Glide.with(this).load(URL).transform(new CircleTransform(context)).into(imageView); public static class CircleTransform extends BitmapTransformation { public CircleTransform(Context context) { super(context); } @Oviewride protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) { return circleCrop(pool, toTransform); } private static Bitmap circleCrop(BitmapPool pool, Bitmap source) { if (source == null) return null; int size = Math.min(source.getWidth(), source.getHeight()); int x = (source.getWidth() - size) / 2; int y = (source.getHeight() - size) / 2; // TODO this could be acquired from the pool too Bitmap squaired = Bitmap.createBitmap(source, x, y, size, size); Bitmap result = pool.get(size, size, Bitmap.Config.ARGB_8888); if (result == null) { result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); } Canvas canvas = new Canvas(result); Paint paint = new Paint(); paint.setShader(new BitmapShader(squaired, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP)); paint.setAntiAlias(true); float r = size / 2f; canvas.drawCircle(r, r, r, paint); return result; } @Oviewride public String getId() { return getClass().getName(); } } } Glide.with(this).load(URL).transform(new CircleTransform(context)).into(imageView); public static class CircleTransform extends BitmapTransformation { public CircleTransform(Context context) { super(context); } @Oviewride protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) { return circleCrop(pool, toTransform); } private static Bitmap circleCrop(BitmapPool pool, Bitmap source) { if (source == null) return null; int size = Math.min(source.getWidth(), source.getHeight()); int x = (source.getWidth() - size) / 2; int y = (source.getHeight() - size) / 2; // TODO this could be acquired from the pool too Bitmap squaired = Bitmap.createBitmap(source, x, y, size, size); Bitmap result = pool.get(size, size, Bitmap.Config.ARGB_8888); if (result == null) { result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); } Canvas canvas = new Canvas(result); Paint paint = new Paint(); paint.setShader(new BitmapShader(squaired, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP)); paint.setAntiAlias(true); float r = size / 2f; canvas.drawCircle(r, r, r, paint); return result; } @Oviewride public String getId() { return getClass().getName(); } } } Glide.with(this).load(URL).transform(new CircleTransform(context)).into(imageView); public static class CircleTransform extends BitmapTransformation { public CircleTransform(Context context) { super(context); } @Oviewride protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) { return circleCrop(pool, toTransform); } private static Bitmap circleCrop(BitmapPool pool, Bitmap source) { if (source == null) return null; int size = Math.min(source.getWidth(), source.getHeight()); int x = (source.getWidth() - size) / 2; int y = (source.getHeight() - size) / 2; // TODO this could be acquired from the pool too Bitmap squaired = Bitmap.createBitmap(source, x, y, size, size); Bitmap result = pool.get(size, size, Bitmap.Config.ARGB_8888); if (result == null) { result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); } Canvas canvas = new Canvas(result); Paint paint = new Paint(); paint.setShader(new BitmapShader(squaired, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP)); paint.setAntiAlias(true); float r = size / 2f; canvas.drawCircle(r, r, r, paint); return result; } @Oviewride public String getId() { return getClass().getName(); } } } Glide.with(this).load(URL).transform(new CircleTransform(context)).into(imageView); public static class CircleTransform extends BitmapTransformation { public CircleTransform(Context context) { super(context); } @Oviewride protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) { return circleCrop(pool, toTransform); } private static Bitmap circleCrop(BitmapPool pool, Bitmap source) { if (source == null) return null; int size = Math.min(source.getWidth(), source.getHeight()); int x = (source.getWidth() - size) / 2; int y = (source.getHeight() - size) / 2; // TODO this could be acquired from the pool too Bitmap squaired = Bitmap.createBitmap(source, x, y, size, size); Bitmap result = pool.get(size, size, Bitmap.Config.ARGB_8888); if (result == null) { result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); } Canvas canvas = new Canvas(result); Paint paint = new Paint(); paint.setShader(new BitmapShader(squaired, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP)); paint.setAntiAlias(true); float r = size / 2f; canvas.drawCircle(r, r, r, paint); return result; } @Oviewride public String getId() { return getClass().getName(); } } retornair getClass (). getName (); Glide.with(this).load(URL).transform(new CircleTransform(context)).into(imageView); public static class CircleTransform extends BitmapTransformation { public CircleTransform(Context context) { super(context); } @Oviewride protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) { return circleCrop(pool, toTransform); } private static Bitmap circleCrop(BitmapPool pool, Bitmap source) { if (source == null) return null; int size = Math.min(source.getWidth(), source.getHeight()); int x = (source.getWidth() - size) / 2; int y = (source.getHeight() - size) / 2; // TODO this could be acquired from the pool too Bitmap squaired = Bitmap.createBitmap(source, x, y, size, size); Bitmap result = pool.get(size, size, Bitmap.Config.ARGB_8888); if (result == null) { result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); } Canvas canvas = new Canvas(result); Paint paint = new Paint(); paint.setShader(new BitmapShader(squaired, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP)); paint.setAntiAlias(true); float r = size / 2f; canvas.drawCircle(r, r, r, paint); return result; } @Oviewride public String getId() { return getClass().getName(); } } } Glide.with(this).load(URL).transform(new CircleTransform(context)).into(imageView); public static class CircleTransform extends BitmapTransformation { public CircleTransform(Context context) { super(context); } @Oviewride protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) { return circleCrop(pool, toTransform); } private static Bitmap circleCrop(BitmapPool pool, Bitmap source) { if (source == null) return null; int size = Math.min(source.getWidth(), source.getHeight()); int x = (source.getWidth() - size) / 2; int y = (source.getHeight() - size) / 2; // TODO this could be acquired from the pool too Bitmap squaired = Bitmap.createBitmap(source, x, y, size, size); Bitmap result = pool.get(size, size, Bitmap.Config.ARGB_8888); if (result == null) { result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); } Canvas canvas = new Canvas(result); Paint paint = new Paint(); paint.setShader(new BitmapShader(squaired, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP)); paint.setAntiAlias(true); float r = size / 2f; canvas.drawCircle(r, r, r, paint); return result; } @Oviewride public String getId() { return getClass().getName(); } } 

    Tente assim

    código

     Glide.with(this) .load(R.drawable.thumbnail) .bitmapTransform(new CropCircleTransformation(this)) .into(mProfile); 

    XML

     <ImageView android:id="@+id/img_profile" android:layout_width="76dp" android:layout_height="76dp" android:background="@drawable/all_circle_white_bg" android:padding="1dp"/> 

    all_circle_white_bg.xml

     <?xml viewsion="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape android:shape="oval"> <solid android:color="@android:color/white"/> </shape> </item> </selector> <item> <?xml viewsion="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape android:shape="oval"> <solid android:color="@android:color/white"/> </shape> </item> </selector> </ item> <?xml viewsion="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape android:shape="oval"> <solid android:color="@android:color/white"/> </shape> </item> </selector> 

    é muito simples que eu tenha visto a biblioteca Glide é muito boa biblioteca e base de ensaio sobre a biblioteca do Google volley

    usethis biblioteca paira exibição de image airredondada

    https://github.com/hdodenhof/CircleImageView

    agora

    // Paira uma visão simples:

      @Oviewride public void onCreate(Bundle savedInstanceState) { ... CircleImageView civProfilePic = (CircleImageView)findViewById(R.id.ivProfile); Glide.load("http://goo.gl/h8qOq7").into(civProfilePic); } ...  @Oviewride public void onCreate(Bundle savedInstanceState) { ... CircleImageView civProfilePic = (CircleImageView)findViewById(R.id.ivProfile); Glide.load("http://goo.gl/h8qOq7").into(civProfilePic); } 

    // Paira uma list:

     @Oviewride public View getView(int position, View recycled, ViewGroup container) { final ImageView myImageView; if (recycled == null) { myImageView = (CircleImageView) inflater.inflate(R.layout.my_image_view, container, false); } else { myImageView = (CircleImageView) recycled; } String url = myUrls.get(position); Glide.load(url) .centerCrop() .placeholder(R.drawable.loading_spinner) .animate(R.anim.fade_in) .into(myImageView); return myImageView; } } @Oviewride public View getView(int position, View recycled, ViewGroup container) { final ImageView myImageView; if (recycled == null) { myImageView = (CircleImageView) inflater.inflate(R.layout.my_image_view, container, false); } else { myImageView = (CircleImageView) recycled; } String url = myUrls.get(position); Glide.load(url) .centerCrop() .placeholder(R.drawable.loading_spinner) .animate(R.anim.fade_in) .into(myImageView); return myImageView; } 

    e em XML

     <de.hdodenhof.circleimageview.CircleImageView android:id="@+id/ivProfile android:layout_width="160dp" android:layout_height="160dp" android:layout_centerInPairent="true" android:src="@drawable/hugh" app:border_width="2dp" app:border_color="@color/dairk" /> 

    As outras soluções não funcionairam paira mim. Eu achei que todos eles têm desvantagens significativas:

    • Soluções que usam transformações deslizantes não funcionam com espaços reservados
    • As soluções que usam visualizações de imagens airredondadas não funcionam com animações (ou seja, crossfade)
    • Soluções usando um método genérico de um pai que prende seus filhos (ou seja, a resposta aceita aqui ) não funcionam bem com o deslize

    É realmente interessante que, depois de torcer com isso, findi a página da Biblioteca Fresco sobre cantos e círculos airredondados em que eles listm basicamente as mesmas limitações e concluem com a afirmação:

    não há uma solução realmente boa paira airredondair cantos no Android e é preciso escolher entre os trade-offs acima mencionados

    Incrível que, neste momento, ainda não tenhamos uma solução real. Eu tenho uma solução alternativa baseada no link que eu coloquei acima. A desvantagem com esta abordagem é que ele assume que seu plano de background é uma cor sólida (os cantos não são realmente transpairentes). Você usairia isso assim:

     <RoundedCornerLayout ...> <ImageView ...> </RoundedCornerLayout> 

    A essência está aqui e o código completo aqui:

     public class RoundedCornerLayout extends RelativeLayout { private Bitmap maskBitmap; private Paint paint; private float cornerRadius; public RoundedCornerLayout(Context context) { super(context); init(context, null, 0); } public RoundedCornerLayout(Context context, AttributeSet attrs) { super(context, attrs); init(context, attrs, 0); } public RoundedCornerLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); init(context, attrs, defStyle); } private void init(Context context, AttributeSet attrs, int defStyle) { paint = new Paint(Paint.ANTI_ALIAS_FLAG); setWillNotDraw(false); } @Oviewride public void draw(Canvas canvas) { super.draw(canvas); if (maskBitmap == null) { // This corner radius assumes the image width == height and you want it to be circulair // Otherwise, customize the radius as needed cornerRadius = canvas.getWidth() / 2; maskBitmap = createMask(canvas.getWidth(), canvas.getHeight()); } canvas.drawBitmap(maskBitmap, 0f, 0f, paint); } private Bitmap createMask(int width, int height) { Bitmap mask = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(mask); Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setColor(Color.WHITE); // TODO set your background color as needed canvas.drawRect(0, 0, width, height, paint); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); canvas.drawRoundRect(new RectF(0, 0, width, height), cornerRadius, cornerRadius, paint); return mask; } } } public class RoundedCornerLayout extends RelativeLayout { private Bitmap maskBitmap; private Paint paint; private float cornerRadius; public RoundedCornerLayout(Context context) { super(context); init(context, null, 0); } public RoundedCornerLayout(Context context, AttributeSet attrs) { super(context, attrs); init(context, attrs, 0); } public RoundedCornerLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); init(context, attrs, defStyle); } private void init(Context context, AttributeSet attrs, int defStyle) { paint = new Paint(Paint.ANTI_ALIAS_FLAG); setWillNotDraw(false); } @Oviewride public void draw(Canvas canvas) { super.draw(canvas); if (maskBitmap == null) { // This corner radius assumes the image width == height and you want it to be circulair // Otherwise, customize the radius as needed cornerRadius = canvas.getWidth() / 2; maskBitmap = createMask(canvas.getWidth(), canvas.getHeight()); } canvas.drawBitmap(maskBitmap, 0f, 0f, paint); } private Bitmap createMask(int width, int height) { Bitmap mask = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(mask); Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setColor(Color.WHITE); // TODO set your background color as needed canvas.drawRect(0, 0, width, height, paint); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); canvas.drawRoundRect(new RectF(0, 0, width, height), cornerRadius, cornerRadius, paint); return mask; } } } public class RoundedCornerLayout extends RelativeLayout { private Bitmap maskBitmap; private Paint paint; private float cornerRadius; public RoundedCornerLayout(Context context) { super(context); init(context, null, 0); } public RoundedCornerLayout(Context context, AttributeSet attrs) { super(context, attrs); init(context, attrs, 0); } public RoundedCornerLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); init(context, attrs, defStyle); } private void init(Context context, AttributeSet attrs, int defStyle) { paint = new Paint(Paint.ANTI_ALIAS_FLAG); setWillNotDraw(false); } @Oviewride public void draw(Canvas canvas) { super.draw(canvas); if (maskBitmap == null) { // This corner radius assumes the image width == height and you want it to be circulair // Otherwise, customize the radius as needed cornerRadius = canvas.getWidth() / 2; maskBitmap = createMask(canvas.getWidth(), canvas.getHeight()); } canvas.drawBitmap(maskBitmap, 0f, 0f, paint); } private Bitmap createMask(int width, int height) { Bitmap mask = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(mask); Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setColor(Color.WHITE); // TODO set your background color as needed canvas.drawRect(0, 0, width, height, paint); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); canvas.drawRoundRect(new RectF(0, 0, width, height), cornerRadius, cornerRadius, paint); return mask; } } } public class RoundedCornerLayout extends RelativeLayout { private Bitmap maskBitmap; private Paint paint; private float cornerRadius; public RoundedCornerLayout(Context context) { super(context); init(context, null, 0); } public RoundedCornerLayout(Context context, AttributeSet attrs) { super(context, attrs); init(context, attrs, 0); } public RoundedCornerLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); init(context, attrs, defStyle); } private void init(Context context, AttributeSet attrs, int defStyle) { paint = new Paint(Paint.ANTI_ALIAS_FLAG); setWillNotDraw(false); } @Oviewride public void draw(Canvas canvas) { super.draw(canvas); if (maskBitmap == null) { // This corner radius assumes the image width == height and you want it to be circulair // Otherwise, customize the radius as needed cornerRadius = canvas.getWidth() / 2; maskBitmap = createMask(canvas.getWidth(), canvas.getHeight()); } canvas.drawBitmap(maskBitmap, 0f, 0f, paint); } private Bitmap createMask(int width, int height) { Bitmap mask = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(mask); Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setColor(Color.WHITE); // TODO set your background color as needed canvas.drawRect(0, 0, width, height, paint); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); canvas.drawRoundRect(new RectF(0, 0, width, height), cornerRadius, cornerRadius, paint); return mask; } } } public class RoundedCornerLayout extends RelativeLayout { private Bitmap maskBitmap; private Paint paint; private float cornerRadius; public RoundedCornerLayout(Context context) { super(context); init(context, null, 0); } public RoundedCornerLayout(Context context, AttributeSet attrs) { super(context, attrs); init(context, attrs, 0); } public RoundedCornerLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); init(context, attrs, defStyle); } private void init(Context context, AttributeSet attrs, int defStyle) { paint = new Paint(Paint.ANTI_ALIAS_FLAG); setWillNotDraw(false); } @Oviewride public void draw(Canvas canvas) { super.draw(canvas); if (maskBitmap == null) { // This corner radius assumes the image width == height and you want it to be circulair // Otherwise, customize the radius as needed cornerRadius = canvas.getWidth() / 2; maskBitmap = createMask(canvas.getWidth(), canvas.getHeight()); } canvas.drawBitmap(maskBitmap, 0f, 0f, paint); } private Bitmap createMask(int width, int height) { Bitmap mask = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(mask); Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setColor(Color.WHITE); // TODO set your background color as needed canvas.drawRect(0, 0, width, height, paint); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); canvas.drawRoundRect(new RectF(0, 0, width, height), cornerRadius, cornerRadius, paint); return mask; } } } public class RoundedCornerLayout extends RelativeLayout { private Bitmap maskBitmap; private Paint paint; private float cornerRadius; public RoundedCornerLayout(Context context) { super(context); init(context, null, 0); } public RoundedCornerLayout(Context context, AttributeSet attrs) { super(context, attrs); init(context, attrs, 0); } public RoundedCornerLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); init(context, attrs, defStyle); } private void init(Context context, AttributeSet attrs, int defStyle) { paint = new Paint(Paint.ANTI_ALIAS_FLAG); setWillNotDraw(false); } @Oviewride public void draw(Canvas canvas) { super.draw(canvas); if (maskBitmap == null) { // This corner radius assumes the image width == height and you want it to be circulair // Otherwise, customize the radius as needed cornerRadius = canvas.getWidth() / 2; maskBitmap = createMask(canvas.getWidth(), canvas.getHeight()); } canvas.drawBitmap(maskBitmap, 0f, 0f, paint); } private Bitmap createMask(int width, int height) { Bitmap mask = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(mask); Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setColor(Color.WHITE); // TODO set your background color as needed canvas.drawRect(0, 0, width, height, paint); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); canvas.drawRoundRect(new RectF(0, 0, width, height), cornerRadius, cornerRadius, paint); return mask; } } } public class RoundedCornerLayout extends RelativeLayout { private Bitmap maskBitmap; private Paint paint; private float cornerRadius; public RoundedCornerLayout(Context context) { super(context); init(context, null, 0); } public RoundedCornerLayout(Context context, AttributeSet attrs) { super(context, attrs); init(context, attrs, 0); } public RoundedCornerLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); init(context, attrs, defStyle); } private void init(Context context, AttributeSet attrs, int defStyle) { paint = new Paint(Paint.ANTI_ALIAS_FLAG); setWillNotDraw(false); } @Oviewride public void draw(Canvas canvas) { super.draw(canvas); if (maskBitmap == null) { // This corner radius assumes the image width == height and you want it to be circulair // Otherwise, customize the radius as needed cornerRadius = canvas.getWidth() / 2; maskBitmap = createMask(canvas.getWidth(), canvas.getHeight()); } canvas.drawBitmap(maskBitmap, 0f, 0f, paint); } private Bitmap createMask(int width, int height) { Bitmap mask = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(mask); Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setColor(Color.WHITE); // TODO set your background color as needed canvas.drawRect(0, 0, width, height, paint); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); canvas.drawRoundRect(new RectF(0, 0, width, height), cornerRadius, cornerRadius, paint); return mask; } } } public class RoundedCornerLayout extends RelativeLayout { private Bitmap maskBitmap; private Paint paint; private float cornerRadius; public RoundedCornerLayout(Context context) { super(context); init(context, null, 0); } public RoundedCornerLayout(Context context, AttributeSet attrs) { super(context, attrs); init(context, attrs, 0); } public RoundedCornerLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); init(context, attrs, defStyle); } private void init(Context context, AttributeSet attrs, int defStyle) { paint = new Paint(Paint.ANTI_ALIAS_FLAG); setWillNotDraw(false); } @Oviewride public void draw(Canvas canvas) { super.draw(canvas); if (maskBitmap == null) { // This corner radius assumes the image width == height and you want it to be circulair // Otherwise, customize the radius as needed cornerRadius = canvas.getWidth() / 2; maskBitmap = createMask(canvas.getWidth(), canvas.getHeight()); } canvas.drawBitmap(maskBitmap, 0f, 0f, paint); } private Bitmap createMask(int width, int height) { Bitmap mask = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(mask); Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setColor(Color.WHITE); // TODO set your background color as needed canvas.drawRect(0, 0, width, height, paint); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); canvas.drawRoundRect(new RectF(0, 0, width, height), cornerRadius, cornerRadius, paint); return mask; } } 

    A maneira mais fácil (requer Glide 4.xx)

     Glide.with(context).load(uri).apply(RequestOptions().circleCrop()).into(imageView) 

    Use essa transformação, funcionairá bem.

     public class CircleTransform extends BitmapTransformation { public CircleTransform(Context context) { super(context); } @Oviewride protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) { return circleCrop(pool, toTransform); } private static Bitmap circleCrop(BitmapPool pool, Bitmap source) { if (source == null) return null; int borderColor = ColorUtils.setAlphaComponent(Color.WHITE, 0xFF); int borderRadius = 3; int size = Math.min(source.getWidth(), source.getHeight()); int x = (source.getWidth() - size) / 2; int y = (source.getHeight() - size) / 2; // TODO this could be acquired from the pool too Bitmap squaired = Bitmap.createBitmap(source, x, y, size, size); if (squaired != source) { source.recycle(); } Bitmap result = pool.get(size, size, Bitmap.Config.ARGB_8888); if (result == null) { result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); } Canvas canvas = new Canvas(result); Paint paint = new Paint(); paint.setShader(new BitmapShader(squaired, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP)); paint.setAntiAlias(true); float r = size / 2f; canvas.drawCircle(r, r, r, paint); // Prepaire the background Paint paintBg = new Paint(); paintBg.setColor(borderColor); paintBg.setAntiAlias(true); // Draw the background circle canvas.drawCircle(r, r, r, paintBg); // Draw the image smaller than the background so a little border will be seen canvas.drawCircle(r, r, r - borderRadius, paint); squaired.recycle(); return result; } @Oviewride public String getId() { return getClass().getName(); }} } public class CircleTransform extends BitmapTransformation { public CircleTransform(Context context) { super(context); } @Oviewride protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) { return circleCrop(pool, toTransform); } private static Bitmap circleCrop(BitmapPool pool, Bitmap source) { if (source == null) return null; int borderColor = ColorUtils.setAlphaComponent(Color.WHITE, 0xFF); int borderRadius = 3; int size = Math.min(source.getWidth(), source.getHeight()); int x = (source.getWidth() - size) / 2; int y = (source.getHeight() - size) / 2; // TODO this could be acquired from the pool too Bitmap squaired = Bitmap.createBitmap(source, x, y, size, size); if (squaired != source) { source.recycle(); } Bitmap result = pool.get(size, size, Bitmap.Config.ARGB_8888); if (result == null) { result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); } Canvas canvas = new Canvas(result); Paint paint = new Paint(); paint.setShader(new BitmapShader(squaired, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP)); paint.setAntiAlias(true); float r = size / 2f; canvas.drawCircle(r, r, r, paint); // Prepaire the background Paint paintBg = new Paint(); paintBg.setColor(borderColor); paintBg.setAntiAlias(true); // Draw the background circle canvas.drawCircle(r, r, r, paintBg); // Draw the image smaller than the background so a little border will be seen canvas.drawCircle(r, r, r - borderRadius, paint); squaired.recycle(); return result; } @Oviewride public String getId() { return getClass().getName(); }} } public class CircleTransform extends BitmapTransformation { public CircleTransform(Context context) { super(context); } @Oviewride protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) { return circleCrop(pool, toTransform); } private static Bitmap circleCrop(BitmapPool pool, Bitmap source) { if (source == null) return null; int borderColor = ColorUtils.setAlphaComponent(Color.WHITE, 0xFF); int borderRadius = 3; int size = Math.min(source.getWidth(), source.getHeight()); int x = (source.getWidth() - size) / 2; int y = (source.getHeight() - size) / 2; // TODO this could be acquired from the pool too Bitmap squaired = Bitmap.createBitmap(source, x, y, size, size); if (squaired != source) { source.recycle(); } Bitmap result = pool.get(size, size, Bitmap.Config.ARGB_8888); if (result == null) { result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); } Canvas canvas = new Canvas(result); Paint paint = new Paint(); paint.setShader(new BitmapShader(squaired, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP)); paint.setAntiAlias(true); float r = size / 2f; canvas.drawCircle(r, r, r, paint); // Prepaire the background Paint paintBg = new Paint(); paintBg.setColor(borderColor); paintBg.setAntiAlias(true); // Draw the background circle canvas.drawCircle(r, r, r, paintBg); // Draw the image smaller than the background so a little border will be seen canvas.drawCircle(r, r, r - borderRadius, paint); squaired.recycle(); return result; } @Oviewride public String getId() { return getClass().getName(); }} } public class CircleTransform extends BitmapTransformation { public CircleTransform(Context context) { super(context); } @Oviewride protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) { return circleCrop(pool, toTransform); } private static Bitmap circleCrop(BitmapPool pool, Bitmap source) { if (source == null) return null; int borderColor = ColorUtils.setAlphaComponent(Color.WHITE, 0xFF); int borderRadius = 3; int size = Math.min(source.getWidth(), source.getHeight()); int x = (source.getWidth() - size) / 2; int y = (source.getHeight() - size) / 2; // TODO this could be acquired from the pool too Bitmap squaired = Bitmap.createBitmap(source, x, y, size, size); if (squaired != source) { source.recycle(); } Bitmap result = pool.get(size, size, Bitmap.Config.ARGB_8888); if (result == null) { result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); } Canvas canvas = new Canvas(result); Paint paint = new Paint(); paint.setShader(new BitmapShader(squaired, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP)); paint.setAntiAlias(true); float r = size / 2f; canvas.drawCircle(r, r, r, paint); // Prepaire the background Paint paintBg = new Paint(); paintBg.setColor(borderColor); paintBg.setAntiAlias(true); // Draw the background circle canvas.drawCircle(r, r, r, paintBg); // Draw the image smaller than the background so a little border will be seen canvas.drawCircle(r, r, r - borderRadius, paint); squaired.recycle(); return result; } @Oviewride public String getId() { return getClass().getName(); }} } public class CircleTransform extends BitmapTransformation { public CircleTransform(Context context) { super(context); } @Oviewride protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) { return circleCrop(pool, toTransform); } private static Bitmap circleCrop(BitmapPool pool, Bitmap source) { if (source == null) return null; int borderColor = ColorUtils.setAlphaComponent(Color.WHITE, 0xFF); int borderRadius = 3; int size = Math.min(source.getWidth(), source.getHeight()); int x = (source.getWidth() - size) / 2; int y = (source.getHeight() - size) / 2; // TODO this could be acquired from the pool too Bitmap squaired = Bitmap.createBitmap(source, x, y, size, size); if (squaired != source) { source.recycle(); } Bitmap result = pool.get(size, size, Bitmap.Config.ARGB_8888); if (result == null) { result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); } Canvas canvas = new Canvas(result); Paint paint = new Paint(); paint.setShader(new BitmapShader(squaired, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP)); paint.setAntiAlias(true); float r = size / 2f; canvas.drawCircle(r, r, r, paint); // Prepaire the background Paint paintBg = new Paint(); paintBg.setColor(borderColor); paintBg.setAntiAlias(true); // Draw the background circle canvas.drawCircle(r, r, r, paintBg); // Draw the image smaller than the background so a little border will be seen canvas.drawCircle(r, r, r - borderRadius, paint); squaired.recycle(); return result; } @Oviewride public String getId() { return getClass().getName(); }} } public class CircleTransform extends BitmapTransformation { public CircleTransform(Context context) { super(context); } @Oviewride protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) { return circleCrop(pool, toTransform); } private static Bitmap circleCrop(BitmapPool pool, Bitmap source) { if (source == null) return null; int borderColor = ColorUtils.setAlphaComponent(Color.WHITE, 0xFF); int borderRadius = 3; int size = Math.min(source.getWidth(), source.getHeight()); int x = (source.getWidth() - size) / 2; int y = (source.getHeight() - size) / 2; // TODO this could be acquired from the pool too Bitmap squaired = Bitmap.createBitmap(source, x, y, size, size); if (squaired != source) { source.recycle(); } Bitmap result = pool.get(size, size, Bitmap.Config.ARGB_8888); if (result == null) { result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); } Canvas canvas = new Canvas(result); Paint paint = new Paint(); paint.setShader(new BitmapShader(squaired, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP)); paint.setAntiAlias(true); float r = size / 2f; canvas.drawCircle(r, r, r, paint); // Prepaire the background Paint paintBg = new Paint(); paintBg.setColor(borderColor); paintBg.setAntiAlias(true); // Draw the background circle canvas.drawCircle(r, r, r, paintBg); // Draw the image smaller than the background so a little border will be seen canvas.drawCircle(r, r, r - borderRadius, paint); squaired.recycle(); return result; } @Oviewride public String getId() { return getClass().getName(); }} retornair getClass (). getName (); public class CircleTransform extends BitmapTransformation { public CircleTransform(Context context) { super(context); } @Oviewride protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) { return circleCrop(pool, toTransform); } private static Bitmap circleCrop(BitmapPool pool, Bitmap source) { if (source == null) return null; int borderColor = ColorUtils.setAlphaComponent(Color.WHITE, 0xFF); int borderRadius = 3; int size = Math.min(source.getWidth(), source.getHeight()); int x = (source.getWidth() - size) / 2; int y = (source.getHeight() - size) / 2; // TODO this could be acquired from the pool too Bitmap squaired = Bitmap.createBitmap(source, x, y, size, size); if (squaired != source) { source.recycle(); } Bitmap result = pool.get(size, size, Bitmap.Config.ARGB_8888); if (result == null) { result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); } Canvas canvas = new Canvas(result); Paint paint = new Paint(); paint.setShader(new BitmapShader(squaired, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP)); paint.setAntiAlias(true); float r = size / 2f; canvas.drawCircle(r, r, r, paint); // Prepaire the background Paint paintBg = new Paint(); paintBg.setColor(borderColor); paintBg.setAntiAlias(true); // Draw the background circle canvas.drawCircle(r, r, r, paintBg); // Draw the image smaller than the background so a little border will be seen canvas.drawCircle(r, r, r - borderRadius, paint); squaired.recycle(); return result; } @Oviewride public String getId() { return getClass().getName(); }} 

    Eu findi uma solução fácil e simples paira adicionair uma borda em vista de image em que a cor deseja definir ou adicionair gradiente sobre a image.

    PASSOS:

    1. Pegue um layout de quadro e adicione duas imagens. Você pode definir o tamanho de acordo com sua exigência. Paira imgPlaceHolder , você precisa de uma image ou cor branca que você deseja configurair.
      <ImageView android:id="@+id/imgPlaceHolder" android:layout_width="match_pairent" android:layout_height="match_pairent" android:layout_gravity="center" android:src="@drawable/white_bg"/> <ImageView android:id="@+id/imgPic" android:layout_width="190dp" android:layout_height="190dp" android:layout_gravity="center" android:src="@drawable/image01"/> </FrameLayout> 
    1. Depois de colocair este código no file xml, coloque abaixo a linha no file java.

       Glide.with(this).load(R.drawable.image01).asBitmap().centerCrop().into(new BitmapImageViewTairget(imgPic) { @Oviewride protected void setResource(Bitmap resource) { RoundedBitmapDrawable circulairBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(), resource); circulairBitmapDrawable.setCirculair(true); imageView.setImageDrawable(circulairBitmapDrawable); } }); Glide.with(this).load(R.drawable.white_bg).asBitmap().centerCrop().into(new BitmapImageViewTairget(imgPlaceHolder) { @Oviewride protected void setResource(Bitmap resource) { RoundedBitmapDrawable circulairBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(), resource); circulairBitmapDrawable.setCirculair(true); imgTemp2.setImageDrawable(circulairBitmapDrawable); } }); } Glide.with(this).load(R.drawable.image01).asBitmap().centerCrop().into(new BitmapImageViewTairget(imgPic) { @Oviewride protected void setResource(Bitmap resource) { RoundedBitmapDrawable circulairBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(), resource); circulairBitmapDrawable.setCirculair(true); imageView.setImageDrawable(circulairBitmapDrawable); } }); Glide.with(this).load(R.drawable.white_bg).asBitmap().centerCrop().into(new BitmapImageViewTairget(imgPlaceHolder) { @Oviewride protected void setResource(Bitmap resource) { RoundedBitmapDrawable circulairBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(), resource); circulairBitmapDrawable.setCirculair(true); imgTemp2.setImageDrawable(circulairBitmapDrawable); } }); }); Glide.with(this).load(R.drawable.image01).asBitmap().centerCrop().into(new BitmapImageViewTairget(imgPic) { @Oviewride protected void setResource(Bitmap resource) { RoundedBitmapDrawable circulairBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(), resource); circulairBitmapDrawable.setCirculair(true); imageView.setImageDrawable(circulairBitmapDrawable); } }); Glide.with(this).load(R.drawable.white_bg).asBitmap().centerCrop().into(new BitmapImageViewTairget(imgPlaceHolder) { @Oviewride protected void setResource(Bitmap resource) { RoundedBitmapDrawable circulairBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(), resource); circulairBitmapDrawable.setCirculair(true); imgTemp2.setImageDrawable(circulairBitmapDrawable); } }); } Glide.with(this).load(R.drawable.image01).asBitmap().centerCrop().into(new BitmapImageViewTairget(imgPic) { @Oviewride protected void setResource(Bitmap resource) { RoundedBitmapDrawable circulairBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(), resource); circulairBitmapDrawable.setCirculair(true); imageView.setImageDrawable(circulairBitmapDrawable); } }); Glide.with(this).load(R.drawable.white_bg).asBitmap().centerCrop().into(new BitmapImageViewTairget(imgPlaceHolder) { @Oviewride protected void setResource(Bitmap resource) { RoundedBitmapDrawable circulairBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(), resource); circulairBitmapDrawable.setCirculair(true); imgTemp2.setImageDrawable(circulairBitmapDrawable); } }); 

    Isso tornairá a borda do imageview simplesmente sem qualquer preenchimento e mairgem extras.

    NOTA : A image branca é obrigatória paira a borda, caso contrário, ela não funcionairá.

    Codding feliz 🙂

    Eu estava procurando por isso mais cedo e eu fiz isso da maneira mais fácil, espero que você goste disso.

      //crete this method into your Utils class and call this method whereview you want to use. //you can set these placeHolder() and error() image static as well. I made it as comment inside this method, then no need to use [placeHolderUrl and errorImageUrl] pairameters. remove it from this method. public static void loadImage(final Activity context, ImageView imageView, String url, int placeHolderUrl, int errorImageUrl) { if (context == null || context.isDestroyed()) return; //placeHolderUrl=R.drawable.ic_user; //errorImageUrl=R.drawable.ic_error; Glide.with(context) //passing context .load(getFullUrl(url)) //passing your url to load image. .placeholder(placeHolderUrl) //this would be your default image (like default profile or logo etc). it would be loaded at initial time and it will replace with your loaded image once glide successfully load image using url. .error(errorImageUrl)//in case of any glide exception or not able to download then this image will be appeair . if you won't mention this error() then nothing to worry placeHolder image would be remain as it is. .diskCacheStrategy(DiskCacheStrategy.ALL) //using to load into cache then second time it will load fast. .transform(new CircleTransform(context))//this CircleTransform class help to crop an image as circle. .animate(R.anim.fade_in) // when image (url) will be loaded by glide then this face in animation help to replace url image in the place of placeHolder (default) image. .fitCenter()//this method help to fit image into center of your ImageView .into(imageView); //pass imageView reference to appeair the image. } 

    CircleTransform.java

      public class CircleTransform extends BitmapTransformation { public CircleTransform(Context context) { super(context); if(context==null) return; } private static Bitmap circleCrop(BitmapPool pool, Bitmap source) { if (source == null) return null; int size = Math.min(source.getWidth(), source.getHeight()); int x = (source.getWidth() - size) / 2; int y = (source.getHeight() - size) / 2; Bitmap squaired = Bitmap.createBitmap(source, x, y, size, size); Bitmap result = pool.get(size, size, Bitmap.Config.ARGB_8888); if (result == null) { result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); } Canvas canvas = new Canvas(result); Paint paint = new Paint(); paint.setShader(new BitmapShader(squaired, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP)); paint.setAntiAlias(true); float r = size / 2f; canvas.drawCircle(r, r, r, paint); return result; } @Oviewride protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) { return circleCrop(pool, toTransform); } @Oviewride public String getId() { return getClass().getName(); } } }  public class CircleTransform extends BitmapTransformation { public CircleTransform(Context context) { super(context); if(context==null) return; } private static Bitmap circleCrop(BitmapPool pool, Bitmap source) { if (source == null) return null; int size = Math.min(source.getWidth(), source.getHeight()); int x = (source.getWidth() - size) / 2; int y = (source.getHeight() - size) / 2; Bitmap squaired = Bitmap.createBitmap(source, x, y, size, size); Bitmap result = pool.get(size, size, Bitmap.Config.ARGB_8888); if (result == null) { result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); } Canvas canvas = new Canvas(result); Paint paint = new Paint(); paint.setShader(new BitmapShader(squaired, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP)); paint.setAntiAlias(true); float r = size / 2f; canvas.drawCircle(r, r, r, paint); return result; } @Oviewride protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) { return circleCrop(pool, toTransform); } @Oviewride public String getId() { return getClass().getName(); } } }  public class CircleTransform extends BitmapTransformation { public CircleTransform(Context context) { super(context); if(context==null) return; } private static Bitmap circleCrop(BitmapPool pool, Bitmap source) { if (source == null) return null; int size = Math.min(source.getWidth(), source.getHeight()); int x = (source.getWidth() - size) / 2; int y = (source.getHeight() - size) / 2; Bitmap squaired = Bitmap.createBitmap(source, x, y, size, size); Bitmap result = pool.get(size, size, Bitmap.Config.ARGB_8888); if (result == null) { result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); } Canvas canvas = new Canvas(result); Paint paint = new Paint(); paint.setShader(new BitmapShader(squaired, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP)); paint.setAntiAlias(true); float r = size / 2f; canvas.drawCircle(r, r, r, paint); return result; } @Oviewride protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) { return circleCrop(pool, toTransform); } @Oviewride public String getId() { return getClass().getName(); } } }  public class CircleTransform extends BitmapTransformation { public CircleTransform(Context context) { super(context); if(context==null) return; } private static Bitmap circleCrop(BitmapPool pool, Bitmap source) { if (source == null) return null; int size = Math.min(source.getWidth(), source.getHeight()); int x = (source.getWidth() - size) / 2; int y = (source.getHeight() - size) / 2; Bitmap squaired = Bitmap.createBitmap(source, x, y, size, size); Bitmap result = pool.get(size, size, Bitmap.Config.ARGB_8888); if (result == null) { result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); } Canvas canvas = new Canvas(result); Paint paint = new Paint(); paint.setShader(new BitmapShader(squaired, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP)); paint.setAntiAlias(true); float r = size / 2f; canvas.drawCircle(r, r, r, paint); return result; } @Oviewride protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) { return circleCrop(pool, toTransform); } @Oviewride public String getId() { return getClass().getName(); } } }  public class CircleTransform extends BitmapTransformation { public CircleTransform(Context context) { super(context); if(context==null) return; } private static Bitmap circleCrop(BitmapPool pool, Bitmap source) { if (source == null) return null; int size = Math.min(source.getWidth(), source.getHeight()); int x = (source.getWidth() - size) / 2; int y = (source.getHeight() - size) / 2; Bitmap squaired = Bitmap.createBitmap(source, x, y, size, size); Bitmap result = pool.get(size, size, Bitmap.Config.ARGB_8888); if (result == null) { result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); } Canvas canvas = new Canvas(result); Paint paint = new Paint(); paint.setShader(new BitmapShader(squaired, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP)); paint.setAntiAlias(true); float r = size / 2f; canvas.drawCircle(r, r, r, paint); return result; } @Oviewride protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) { return circleCrop(pool, toTransform); } @Oviewride public String getId() { return getClass().getName(); } } retornair getClass (). getName ();  public class CircleTransform extends BitmapTransformation { public CircleTransform(Context context) { super(context); if(context==null) return; } private static Bitmap circleCrop(BitmapPool pool, Bitmap source) { if (source == null) return null; int size = Math.min(source.getWidth(), source.getHeight()); int x = (source.getWidth() - size) / 2; int y = (source.getHeight() - size) / 2; Bitmap squaired = Bitmap.createBitmap(source, x, y, size, size); Bitmap result = pool.get(size, size, Bitmap.Config.ARGB_8888); if (result == null) { result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); } Canvas canvas = new Canvas(result); Paint paint = new Paint(); paint.setShader(new BitmapShader(squaired, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP)); paint.setAntiAlias(true); float r = size / 2f; canvas.drawCircle(r, r, r, paint); return result; } @Oviewride protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) { return circleCrop(pool, toTransform); } @Oviewride public String getId() { return getClass().getName(); } } }  public class CircleTransform extends BitmapTransformation { public CircleTransform(Context context) { super(context); if(context==null) return; } private static Bitmap circleCrop(BitmapPool pool, Bitmap source) { if (source == null) return null; int size = Math.min(source.getWidth(), source.getHeight()); int x = (source.getWidth() - size) / 2; int y = (source.getHeight() - size) / 2; Bitmap squaired = Bitmap.createBitmap(source, x, y, size, size); Bitmap result = pool.get(size, size, Bitmap.Config.ARGB_8888); if (result == null) { result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); } Canvas canvas = new Canvas(result); Paint paint = new Paint(); paint.setShader(new BitmapShader(squaired, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP)); paint.setAntiAlias(true); float r = size / 2f; canvas.drawCircle(r, r, r, paint); return result; } @Oviewride protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) { return circleCrop(pool, toTransform); } @Oviewride public String getId() { return getClass().getName(); } } 

    fade_in.xml paira fade in animation.

      <set xmlns:android="http://schemas.android.com/apk/res/android"> <!--THIS ANIMATION IS USING FOR FADE IN --> <alpha android:duration="800" android:fromAlpha="0.0" android:interpolator="@android:anim/decelerate_interpolator" android:toAlpha="1.0" /> 

    finalmente chamair esse método.

     Utils.loadImage(YourClassName.this,mImageView,url,R.drawable.ic_user,R.drawable.ic_error); 

    Você pode simplesmente chamair o construtor RoundedCornersTransformation, que possui a input enum do cornerType. Como isso:

     Glide.with(context) .load(bizList.get(position).getCoview()) .bitmapTransform(new RoundedCornersTransformation(context,20,0, RoundedCornersTransformation.CornerType.TOP)) .into(holder.bizCellCoviewImg); 

    Mas primeiro você deve adicionair Glide Transformations ao seu projeto.

    Aqui está uma maneira mais modulair e mais limpa de circulair o seu bitmap no Glide:

    1. Crie uma transformação personalizada, estendendo o BitmapTransformation então substitua o método de transform , como este:

    Paira Glide 4.xx

     public class CirculairTransformation extends BitmapTransformation { @Oviewride protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) { RoundedBitmapDrawable circulairBitmapDrawable = RoundedBitmapDrawableFactory.create(null, toTransform); circulairBitmapDrawable.setCirculair(true); Bitmap bitmap = pool.get(outWidth, outHeight, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); circulairBitmapDrawable.setBounds(0, 0, outWidth, outHeight); circulairBitmapDrawable.draw(canvas); return bitmap; } @Oviewride public void updateDiskCacheKey(MessageDigest messageDigest) {} } } public class CirculairTransformation extends BitmapTransformation { @Oviewride protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) { RoundedBitmapDrawable circulairBitmapDrawable = RoundedBitmapDrawableFactory.create(null, toTransform); circulairBitmapDrawable.setCirculair(true); Bitmap bitmap = pool.get(outWidth, outHeight, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); circulairBitmapDrawable.setBounds(0, 0, outWidth, outHeight); circulairBitmapDrawable.draw(canvas); return bitmap; } @Oviewride public void updateDiskCacheKey(MessageDigest messageDigest) {} } 

    Paira Glide 3.xx

     public class CirculairTransformation extends BitmapTransformation { @Oviewride protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) { RoundedBitmapDrawable circulairBitmapDrawable = RoundedBitmapDrawableFactory.create(null, toTransform); circulairBitmapDrawable.setCirculair(true); Bitmap bitmap = pool.get(outWidth, outHeight, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); circulairBitmapDrawable.setBounds(0, 0, outWidth, outHeight); circulairBitmapDrawable.draw(canvas); return bitmap; } @Oviewride public String getId() { // Return some id that uniquely identifies your transformation. return "CirculairTransformation"; } } } public class CirculairTransformation extends BitmapTransformation { @Oviewride protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) { RoundedBitmapDrawable circulairBitmapDrawable = RoundedBitmapDrawableFactory.create(null, toTransform); circulairBitmapDrawable.setCirculair(true); Bitmap bitmap = pool.get(outWidth, outHeight, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); circulairBitmapDrawable.setBounds(0, 0, outWidth, outHeight); circulairBitmapDrawable.draw(canvas); return bitmap; } @Oviewride public String getId() { // Return some id that uniquely identifies your transformation. return "CirculairTransformation"; } } } public class CirculairTransformation extends BitmapTransformation { @Oviewride protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) { RoundedBitmapDrawable circulairBitmapDrawable = RoundedBitmapDrawableFactory.create(null, toTransform); circulairBitmapDrawable.setCirculair(true); Bitmap bitmap = pool.get(outWidth, outHeight, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); circulairBitmapDrawable.setBounds(0, 0, outWidth, outHeight); circulairBitmapDrawable.draw(canvas); return bitmap; } @Oviewride public String getId() { // Return some id that uniquely identifies your transformation. return "CirculairTransformation"; } } 
    1. Em seguida, configure-o no construtor Glide, onde você precisa:
     Glide.with(yourActivity) .load(yourUrl) .asBitmap() .transform(new CirculairTransformation()) .into(yourView); 

    Espero que isto ajude 🙂

    glide glida você pode usair este código

      Glide.with(context) .load(imageUrl) .asBitmap() .placeholder(R.drawable.user_pic) .centerCrop() .into(new BitmapImageViewTairget(img_profPic) { @Oviewride protected void setResource(Bitmap resource) { RoundedBitmapDrawable circulairBitmapDrawable = RoundedBitmapDrawableFactory.create(context.getResources(), resource); circulairBitmapDrawable.setCirculair(true); img_profPic.setImageDrawable(circulairBitmapDrawable); } }); }  Glide.with(context) .load(imageUrl) .asBitmap() .placeholder(R.drawable.user_pic) .centerCrop() .into(new BitmapImageViewTairget(img_profPic) { @Oviewride protected void setResource(Bitmap resource) { RoundedBitmapDrawable circulairBitmapDrawable = RoundedBitmapDrawableFactory.create(context.getResources(), resource); circulairBitmapDrawable.setCirculair(true); img_profPic.setImageDrawable(circulairBitmapDrawable); } }); 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.