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

AppCompatImageView

open class AppCompatImageView : ImageView, TintableBackgroundView, TintableImageSourceView
kotlin.Any
   ↳ 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.

Summary

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

<init>

AppCompatImageView(context: Context!)

<init>

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

<init>

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

Public methods

hasOverlappingRendering

open fun hasOverlappingRendering(): Boolean

setBackgroundDrawable

open fun setBackgroundDrawable(background: Drawable!): Unit

setBackgroundResource

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

setImageBitmap

open fun setImageBitmap(bm: Bitmap!): Unit

setImageDrawable

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

setImageResource

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.

Parameters
resId Int: the resource identifier of the drawable

setImageURI

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

Protected methods

drawableStateChanged

protected open fun drawableStateChanged(): Unit