Image View

Set Image Url

This function loads an image from a URL into an ImageView with a placeholder, error image, and optional center crop.

  • context: The context to use for Glide.

  • imageUrl: The URL of the image to load.

  • placeholder?: Resource ID of the placeholder image.

  • error?: Resource ID of the error image.

  • isCenterCrop?: Boolean to determine if the image should be center cropped.

? is nullable

Usage:

imageView.setImageUrl(this, "https://example.com/image.jpg", true)
imageView.setImageUrl(this, "https://example.com/image.jpg", R.drawable.placeholder, true)
imageView.setImageUrl(this, "https://example.com/image.jpg", R.drawable.placeholder, R.drawable.error, true)

This example demonstrates how to use the setImageUrl extension functions to load images into an ImageView with different options for placeholders, error images, and center cropping.

Last updated