问题描述
今天,我试图在我的android应用程序中使用Glide4图像加载器,而与此同时我却面临着无法解决问题的方法.我进行了很多搜索,还找到了解决方案,我必须创建RequestOptions并像这样使用:
Today I'm trying to use Glide4 image loader in my android application while using this I had facing method not resolving problem. I have searched a lot and also found a solution, I have to created RequestOptions and use like this:
private void loadImages() {
RequestOptions requestOptions = new RequestOptions();
requestOptions.placeholder(R.drawable.circle_diff);
requestOptions.centerCrop();
Glide.with(this)
.load("http://localhost/ImageRepo/profile.jpg")
.apply(requestOptions)
.into(new BitmapImageViewTarget(mBinding.profilePic){
@Override
protected void setResource(Bitmap resource) {
RoundedBitmapDrawable circularBitmapDrawable =
RoundedBitmapDrawableFactory.create(getResources(), resource);
circularBitmapDrawable.setCircular(true);
mBinding.profilePic.setImageDrawable(circularBitmapDrawable);
}
});
但是在 .into 方法中,出现了Cannot resolve method 'into(anonymous com.bumptech.glide.request.target.BitmapImageViewTarget)
错误.发生什么事了?
but in .into method i got Cannot resolve method 'into(anonymous com.bumptech.glide.request.target.BitmapImageViewTarget)
error. Whats happen ??
我的应用程序gradle依赖项:
My App gradle dependencies:
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation("com.github.bumptech.glide:glide:4.6.1") {
exclude group: "com.android.support"
}
implementation "com.android.support:support-fragment:26.1.0"
annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
}
推荐答案
尝试使用 requestOptions.circleCropTransform();
Try this Use requestOptions.circleCropTransform();
RequestOptions requestOptions = new RequestOptions();
requestOptions.placeholder(R.drawable.ic_launcher_background);
requestOptions.circleCropTransform();
requestOptions.transforms( new RoundedCorners(300));
Glide.with(this)
.load("https://i.stack.imgur.com/7CChZ.jpg?s=328&g=1")
.apply(requestOptions)
.into(imageView);
输出
这篇关于Glid4-BitmapImageViewTarget在into方法中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!