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