glide-transformations 使用笔记

引入:

  implementation 'jp.wasabeef:glide-transformations:4.0.1'

常用的几种效果

Crop(剪裁: 圆角,圆形,正方形..)

CropTransformationCropCircleTransformationCropSquareTransformationRoundedCornersTransformation

Color(过滤色: 素描,反转...)

ColorFilterTransformationGrayscaleTransformation

Blur(模糊..)

BlurTransformation

Mask(遮罩..)

MaskTransformation 

MultiTransformation 可以同时设置多个transformations,官方示例:

val multi = MultiTransformation<Bitmap>(
  BlurTransformation(25),
  RoundedCornersTransformation(128, 0, CornerType.ALL))
Glide.with(this).load(R.drawable.demo)
  .apply(bitmapTransform(multi))
  .into(imageView) 

遇到一个小问题: 

RoundedCornersTransformation 圆角效果

在xml 中设置 

android:scaleType="centerCrop"

这的时候,不起效果,其他center,fit等可以显示圆角效果,这咋解决呢? 

看github 上有不少同志遇到过这个问题:

https://github.com/wasabeef/glide-transformations/issues/16

我尝试了下面的方法,可以显示:

 Glide.with(this).load(imgUrl2).transform(
            CenterCrop(),
            RoundedCorners(25)
        ).into(ivTeacherIcon)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章