1.CenterCrop與Transformer的共存問(wèn)題
因?yàn)榇?a target="_blank" rel="nofollow">bug無(wú)法在使用GridLayoutManager和StaggeredGridLayoutManager等其他情況中使用.centerCrop選項(xiàng)揍庄,所以要實(shí)現(xiàn)此功能需要在ImageView中去設(shè)置scaleType為centerCrop
But,如果你想同時(shí)讓圖片有圓角之類的Transformer丐枉,比如在Glide中.transform()配置了一個(gè)圓角矩形,那如果同時(shí)ImageView的scaleType設(shè)置了centerCrop,那圓角就沒(méi)有了
要解決此問(wèn)題需要設(shè)置兩個(gè)Transformer灭将,在我的項(xiàng)目中像這樣:
.transform(new CenterCrop(getContext())
,new GlideRoundTransform(getContext(), 20))
這樣完美解決問(wèn)題嫂沉。
附上圓角的代碼:
GlideRoundTransform 代碼
https://github.com/wasabeef/glide-transformations/issues/16
https://github.com/bumptech/glide/issues/613