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()
2
Answers
You dont need to create separate
thread
for loading becauseGlide
does it for you. Just:Will be enough
Glide not required thread.it work on ui thread async manner.also check your image size and internet connection.