为什么我在使用时无法解决此方法Glide
我也无法解决.diskstaretegy()
:
Glide.with(getActivity())
.load(chalet.profilePhoto)
.asBitmap() <--- cannot resolve this
.diskCacheStrategy(DiskCacheStrategy.ALL) <--- cannot reslove this
.fitCenter()
.placeholder(R.drawable.logo).dontAnimate().into(mImageView);
Run Code Online (Sandbox Code Playgroud)
我的朋友: -
compile 'com.github.bumptech.glide:glide:4.0.0'
Run Code Online (Sandbox Code Playgroud)
Ara*_*our 41
我找到了修复它的方法,你必须添加asBitmap()
正确的After with()
,它将像以前一样工作.
PS:我的滑翔版是4.7.1
Sam*_*ani 19
对于asBitmap,您需要按如下方式编写它:
Glide.with(getActivity()).asBitmap().load(chalet.profilePhoto).into(mImageView);
Run Code Online (Sandbox Code Playgroud)
Muh*_*sim 10
// Put asBitmap() right after Glide.with(context) ,,. 4.0+
// And for SubsamplingScaleImageView use SimpleTarget
Glide.with(context)
.asBitmap()
.load(images[position])
.apply(RequestOptions.diskCacheStrategyOf(DiskCacheStrategy.AUTOMATIC))
.into(new SimpleTarget<Bitmap>(width, height) {
@Override
public void onResourceReady(Bitmap bitmap, Transition<? super Bitmap> transition) {
subsampleImageView.setImage(ImageSource.bitmap(bitmap)); //For SubsampleImage
}
});
Run Code Online (Sandbox Code Playgroud)
如果出现错误,请按照以下步骤操作。
在 Glide 库中移动.asBitmap()
之前.load()
- - - - - - - - - - -或者 - - - - - - - - - - - -
Glide.with(context)
.setDefaultRequestOptions(requestOptions)
.asBitmap()
.load(url)
.into(holder.imageView);
Run Code Online (Sandbox Code Playgroud)
https://bumptech.github.io/glide/doc/migrating.html#requestoptions
Glide.with(getActivity()).asBitmap()
.load(headerURl)
.listener(new RequestListener<Bitmap>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object o, Target<Bitmap> target, boolean b) {
// Toast.makeText(cxt,getResources().getString(R.string.unexpected_error_occurred_try_again),Toast.LENGTH_SHORT).show();
return false;
}
@Override
public boolean onResourceReady(Bitmap bitmap, Object o, Target<Bitmap> target, DataSource dataSource, boolean b) {
if (null == header)
return false;
//set image
header.setImageBitmap(bitmap);
//process bitmap
Palette.from(bitmap).generate(
new Palette.PaletteAsyncListener() {
@SuppressWarnings("ResourceType")
@Override
public void onGenerated(Palette palette) {
int vibrantColor = palette
.getVibrantColor(R.color.primary_500);
int vibrantDarkColor = palette
.getDarkVibrantColor(R.color.primary_700);
collapsingToolbarLayout
.setContentScrimColor(vibrantColor);
collapsingToolbarLayout
.setStatusBarScrimColor(vibrantDarkColor);
}
});
return false;
}
}
).submit();
Run Code Online (Sandbox Code Playgroud)
小智 6
致电asBitmap()
之前load()
Glide.with(context)
.asBitmap()
.load(uri)
Run Code Online (Sandbox Code Playgroud)
你可以用另一种方式设置它
RequestOptions requestOptions = new RequestOptions();
requestOptions.placeholder(R.drawable.ic_placeholder);
requestOptions.diskCacheStrategy(DiskCacheStrategy.ALL)
requestOptions.error(R.drawable.ic_error);
Glide.with(context)
.setDefaultRequestOptions(requestOptions)
.asBitmap()
.load(url).into(holder.imageView);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
14262 次 |
最近记录: |