Glide 不解析它的方法
Glide does not resolve its method
今天我试图在我的 android 应用程序中使用 Glide
图像加载器,同时使用它时我遇到了无法解决问题的方法。
Glide
.with(this)
.load(R.drawable.image_default_profile_picture)
.into(mUserImage);
此代码运行良好。但是当我尝试这个时
Glide
.with(this)
.load(R.drawable.image_default_profile_picture)
.placeholder(R.mipmap.ic_launcher)
.fitCenter()
.into(mUserImage);
那么这句话无法解析方法fitCenter()
,placeholder
。
我缺少什么?
编译这个库:-
compile 'com.github.bumptech.glide:glide:3.7.0'
似乎更新的库有任何问题。添加 .apply(new RequestOptions()
以继续使用最新版本。
代码
Glide
.with(this)
.load(R.drawable.image_default_profile_picture)
.apply(new RequestOptions()
.placeholder(R.mipmap.ic_launcher)
.fitCenter())
.into(mUserImage);
要在从 v4.0 开始的 Glide 版本中使用 fitCenter()
和其他音阶类型更改,您需要在您的应用中包含特殊的 class。
import com.bumptech.glide.annotation.GlideModule;
import com.bumptech.glide.module.AppGlideModule;
@GlideModule
public class MyAppGlideModule extends AppGlideModule {
}
重建项目后,就可以开始使用Glide了
GlideApp.with(imageView)
.load("...")
.fitCenter()
.into(imageView);
如果您仍想使用最新的库 'com.github.bumptech.glide:glide:4.0.0-RC1'
,The official Github page 建议如下:
Round Pictures: CircleImageView/CircularImageView/RoundedImageView are
known to have issues with TransitionDrawable (.crossFade() with
.thumbnail() or .placeholder()) and animated GIFs, use a
BitmapTransformation (.circleCrop() will be available in v4) or
.dontAnimate() to fix the issue.
否则使用以下库版本:
compile 'com.github.bumptech.glide:glide:3.7.0'
您仍然可以在最新版本的 Glide 中使用 .placeholder()
,您只需将其添加为方法链中的已应用 RequestOption
,即
Glide.with(this)
.load(floorplanUrl)
.apply(new RequestOptions()
.placeholder(R.drawable.floorplan_unavailable))
.into(floorplanImageView);
如果你使用 Glide 包依赖 compile 'com.github.bumptech.glide:glide:3.7.0'
而不是使用下面的代码
Glide
.with(your_context)
.load(image_url)
.centerCrop()
.placeholder(R.drawable.image_loading)
.error(R.drawable.image_error)
.into(imageView);
Note: As in doc
Round Pictures: CircleImageView/CircularImageView/RoundedImageView are
known to have issues with TransitionDrawable (.crossFade() with
.thumbnail() or .placeholder()) and animated GIFs, use a
BitmapTransformation (.circleCrop() will be available in v4) or
.dontAnimate() to fix the issue.
最新更新版本 compile 'com.github.bumptech.glide:glide:4.1.1'
或更高版本比使用下面的代码
Glide.with(your_context)
.load(url)
.apply(new RequestOptions()
.placeholder(R.mipmap.ic_loading_image)
.centerCrop()
.dontAnimate()
.dontTransform())
.into(imageView);
如果您想使用 compile 'com.github.bumptech.glide:glide:3.7.0'
将 GIF File
加载到 Glide
中,而不是使用 .asGif()
方法在.load()
之后
Glide
.with(your_context)
.load(image_url)
.asGif()
.into(imageView);
如果您使用 compile 'com.github.bumptech.glide:glide:4.1.1'
或比
更高(最新)的依赖项
Glide
.with(your_context)
.asGif()
.load(image_url)
.into(imageView);
Note: If you are useing glide:glide:4.1.1
or higher version than not necessary to use .asGif() method to load GIF
file it will
load GIF File
automatically
See Latest version of glide, Bug fixes, Features
滑行版本:4.8.0
Glide.with(this)
.load("https://media.giphy.com/media/98uBZTzlXMhkk/giphy.gif")
.apply(new RequestOptions()
.placeholder(R.drawable.placeholder)
.error(R.drawable.error)
.centerCrop()
.fitCenter())
.into(imageView);
今天我试图在我的 android 应用程序中使用 Glide
图像加载器,同时使用它时我遇到了无法解决问题的方法。
Glide
.with(this)
.load(R.drawable.image_default_profile_picture)
.into(mUserImage);
此代码运行良好。但是当我尝试这个时
Glide
.with(this)
.load(R.drawable.image_default_profile_picture)
.placeholder(R.mipmap.ic_launcher)
.fitCenter()
.into(mUserImage);
那么这句话无法解析方法fitCenter()
,placeholder
。
我缺少什么?
编译这个库:-
compile 'com.github.bumptech.glide:glide:3.7.0'
似乎更新的库有任何问题。添加 .apply(new RequestOptions()
以继续使用最新版本。
代码
Glide
.with(this)
.load(R.drawable.image_default_profile_picture)
.apply(new RequestOptions()
.placeholder(R.mipmap.ic_launcher)
.fitCenter())
.into(mUserImage);
要在从 v4.0 开始的 Glide 版本中使用 fitCenter()
和其他音阶类型更改,您需要在您的应用中包含特殊的 class。
import com.bumptech.glide.annotation.GlideModule;
import com.bumptech.glide.module.AppGlideModule;
@GlideModule
public class MyAppGlideModule extends AppGlideModule {
}
重建项目后,就可以开始使用Glide了
GlideApp.with(imageView)
.load("...")
.fitCenter()
.into(imageView);
如果您仍想使用最新的库 'com.github.bumptech.glide:glide:4.0.0-RC1'
,The official Github page 建议如下:
Round Pictures: CircleImageView/CircularImageView/RoundedImageView are known to have issues with TransitionDrawable (.crossFade() with .thumbnail() or .placeholder()) and animated GIFs, use a BitmapTransformation (.circleCrop() will be available in v4) or .dontAnimate() to fix the issue.
否则使用以下库版本:
compile 'com.github.bumptech.glide:glide:3.7.0'
您仍然可以在最新版本的 Glide 中使用 .placeholder()
,您只需将其添加为方法链中的已应用 RequestOption
,即
Glide.with(this)
.load(floorplanUrl)
.apply(new RequestOptions()
.placeholder(R.drawable.floorplan_unavailable))
.into(floorplanImageView);
如果你使用 Glide 包依赖 compile 'com.github.bumptech.glide:glide:3.7.0'
而不是使用下面的代码
Glide
.with(your_context)
.load(image_url)
.centerCrop()
.placeholder(R.drawable.image_loading)
.error(R.drawable.image_error)
.into(imageView);
Note: As in doc Round Pictures: CircleImageView/CircularImageView/RoundedImageView are known to have issues with TransitionDrawable (.crossFade() with .thumbnail() or .placeholder()) and animated GIFs, use a BitmapTransformation (.circleCrop() will be available in v4) or .dontAnimate() to fix the issue.
最新更新版本 compile 'com.github.bumptech.glide:glide:4.1.1'
或更高版本比使用下面的代码
Glide.with(your_context)
.load(url)
.apply(new RequestOptions()
.placeholder(R.mipmap.ic_loading_image)
.centerCrop()
.dontAnimate()
.dontTransform())
.into(imageView);
如果您想使用 compile 'com.github.bumptech.glide:glide:3.7.0'
将 GIF File
加载到 Glide
中,而不是使用 .asGif()
方法在.load()
Glide
.with(your_context)
.load(image_url)
.asGif()
.into(imageView);
如果您使用 compile 'com.github.bumptech.glide:glide:4.1.1'
或比
Glide
.with(your_context)
.asGif()
.load(image_url)
.into(imageView);
Note: If you are useing
glide:glide:4.1.1
or higher version than not necessary to use .asGif() method to loadGIF
file it will loadGIF File
automaticallySee Latest version of glide, Bug fixes, Features
滑行版本:4.8.0
Glide.with(this)
.load("https://media.giphy.com/media/98uBZTzlXMhkk/giphy.gif")
.apply(new RequestOptions()
.placeholder(R.drawable.placeholder)
.error(R.drawable.error)
.centerCrop()
.fitCenter())
.into(imageView);