Download¶
Add the codes below to your root build.gradle
file (not your module-level build.gradle file):
allprojects {
repositories {
mavenCentral()
}
}
Next, add the dependency below to your module's build.gradle
file:
dependencies {
implementation "com.github.skydoves:landscapist-glide:2.4.2"
}
dependencies {
implementation("com.github.skydoves:landscapist-glide:2.4.2")
}
Note
Landscapist-Glide
includes version 4.15.1
of Glide internally. So please make sure your project uses the same Glide version or exclude the Glide dependency to adapt yours. Also, please make sure the Jetpack Compose version on the release page.
GlideImage¶
You can load images simply by using GlideImage
composable function as the following example below:
GlideImage(
imageModel = { imageUrl }, // loading a network image using an URL.
imageOptions = ImageOptions(
contentScale = ContentScale.Crop,
alignment = Alignment.Center
)
)
Compose Metrics¶
According to the Compose Compoler Metrics, the GlideImage
Composable function is marked as Restartable and Skippable. This means you don't have to worry about performance issues related to re-rendering or re-fetching problems that can occur during recomposition. The Composable function's restartable and skippable nature ensures that the necessary actions are taken to optimize rendering, making it more efficient and seamless.