2

I'm trying to display an image using Glide in my ImageView to no avail. I don't get any errors, but I don't see any image either

build.gradle dependencies:

 implementation 'com.github.bumptech.glide:glide:4.12.0'
 annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'

my ImageView Layout:

       <ImageView
                    android:id="@+id/profilPicture"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentTop="true"
                    android:layout_centerHorizontal="true"
                    android:src="@drawable/medicine">

       </ImageView>

In my MainActivity I try to display the image within a thread

       val thread = Thread {
        try {
            Glide.with(this)
                .load("http://via.placeholder.com/300.png")
                .into(profilPicture)
        } catch (e: Exception) {
            e.printStackTrace()
        }
    }

    thread.start()
Captai-N
  • 1,124
  • 3
  • 15
  • 26
  • Mention the log. And it might be that your image is loaded but due to background it is now visible clearly. Have you used `listener` to check either the resource is successfully loaded or not? – Kamal Nayan Jan 28 '22 at 10:05
  • Why are you doing it using a thread though? – Sujal Kumar Jan 28 '22 at 10:26

2 Answers2

2

Glide not required thread.it work on ui thread async manner.also check your image size and internet connection.

Glide.with(this).load(url).into(view);
1

You dont need to create separate thread for loading because Glide does it for you. Just:

Glide.with(this)
    .load("http://via.placeholder.com/300.png")
    .into(profilPicture)

Will be enough

Andrey Danilov
  • 6,194
  • 5
  • 32
  • 56