結合Glide實現很炫的圖片效果框架
開源項目地址:https://github.com/open-android/Glide-transformations
PS:如果覺得文章太長,你也可觀看該課程的視頻,親,裏面還有高清,無碼的福利喔
運行效果
- 歡迎關注微信公衆號
微信公衆號名稱:Android乾貨程序員
使用步驟
1. 在project的build.gradle添加如下代碼(如下圖)
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
2. 在Module的build.gradle添加依賴
compile 'com.github.open-android:Glide-transformations:0.1.0'
3. 使用Picasso加載圖片時添加顯示效果
Glide.with(context)
.load(url)
.transform(new CropCircleTransformation())//圖片最終會展示出圓形區域
.into(view);
Glide-transformations 是通過Glide加載圖片中通過上面的transform可以設置圖片展示的效果 CropCircleTransformation是圓形效果,還有很多其他的效果
模糊效果
Glide.with(this)
.load(R.mipmap.ic_image_sample)
.bitmapTransform(new BlurTransformation(this))
.into(mResultIv);
圓角效果
Glide.with(this).load(R.mipmap.ic_image_sample)
.bitmapTransform(new RoundedCornersTransformation(this, 24, 0,
RoundedCornersTransformation.CornerType.ALL))
.into(mResultIv);
遮蓋效果
Glide.with(this).load(R.mipmap.ic_image_sample)
.bitmapTransform(new MaskTransformation(this, R.mipmap.ic_launcher))
.into(mResultIv);
灰度效果
Glide.with(this).load(R.mipmap.ic_image_sample)
.bitmapTransform(new GrayscaleTransformation(this))
.into(mResultIv);
其他效果
ToonFilterTransformation
SepiaFilterTransformation
ContrastFilterTransformation
InvertFilterTransformation
PixelationFilterTransformation
SketchFilterTransformation
SwirlFilterTransformation
BrightnessFilterTransformation
KuwaharaFilterTransformation
VignetteFilterTransformation