1

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);
        }
    });

but in .into method i got Cannot resolve method 'into(anonymous com.bumptech.glide.request.target.BitmapImageViewTarget) error. Whats happen ??

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'
}
Cyrus the Great
  • 5,145
  • 5
  • 68
  • 149

1 Answers1

4

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);        

OUTPUT

enter image description here

AskNilesh
  • 67,701
  • 16
  • 123
  • 163