open class AppCompatImageView : ImageView, TintableBackgroundView, TintableImageSourceView
   ↳ android.view.View
   ↳ android.widget.ImageView
   ↳ androidx.appcompat.widget.AppCompatImageView

A ImageView which supports compatible features on older versions of the platform, including:

  • Allows dynamic tint of its background via the background tint methods in androidx.core.view.ViewCompat.
  • Allows setting of the background tint using androidx.appcompat.R.attr#backgroundTint and androidx.appcompat.R.attr#backgroundTintMode.
  • Allows dynamic tint of its image via the image tint methods in ImageViewCompat.
  • Allows setting of the image tint using androidx.appcompat.R.attr#tint and androidx.appcompat.R.attr#tintMode.

This will automatically be used when you use ImageView in your layouts and the top-level activity / dialog is provided by appcompat. You should only need to manually use this class when writing custom views.


Public constructors

<init>(@NonNull context: Context)

<init>(@NonNull context: Context, @Nullable attrs: AttributeSet?)

<init>(@NonNull context: Context, @Nullable attrs: AttributeSet?, defStyleAttr: Int)

Public methods

open Boolean

open Unit

open Unit
setBackgroundResource(@DrawableRes resId: Int)

open Unit

open Unit
setImageDrawable(@Nullable drawable: Drawable?)

open Unit
setImageResource(@DrawableRes resId: Int)

Sets a drawable as the content of this ImageView.

open Unit
setImageURI(@Nullable uri: Uri?)

Protected methods

open Unit

Public constructors


AppCompatImageView(@NonNull context: Context)


AppCompatImageView(@NonNull context: Context, @Nullable attrs: AttributeSet?)


AppCompatImageView(@NonNull context: Context, @Nullable attrs: AttributeSet?, defStyleAttr: Int)

Public methods


open fun hasOverlappingRendering(): Boolean


open fun setBackgroundDrawable(background: Drawable!): Unit


open fun setBackgroundResource(@DrawableRes resId: Int): Unit


open fun setImageBitmap(bm: Bitmap!): Unit


open fun setImageDrawable(@Nullable drawable: Drawable?): Unit


open fun setImageResource(@DrawableRes resId: Int): Unit

Sets a drawable as the content of this ImageView.

Allows the use of vector drawables when running on older versions of the platform.

resId Int: the resource identifier of the drawable


open fun setImageURI(@Nullable uri: Uri?): Unit

Protected methods


protected open fun drawableStateChanged(): Unit