The Android Developer Challenge is back! Submit your idea before December 2.


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 R.attr#backgroundTint and R.attr#backgroundTintMode.
  • Allows dynamic tint of its image via the image tint methods in ImageViewCompat.
  • Allows setting of the image tint using R.attr#tint and 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>(context: Context!)

<init>(context: Context!, attrs: AttributeSet!)

<init>(context: Context!, 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(context: Context!)


AppCompatImageView(context: Context!, attrs: AttributeSet!)


AppCompatImageView(context: Context!, 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