Most visited

Recently visited

AppCompatImageButton

public class AppCompatImageButton
extends ImageButton implements TintableBackgroundView

java.lang.Object
   ↳ android.view.View
     ↳ android.widget.ImageView
       ↳ android.widget.ImageButton
         ↳ android.support.v7.widget.AppCompatImageButton


A ImageButton which supports compatible features on older version of the platform, including:

This will automatically be used when you use ImageButton in your layouts. You should only need to manually use this class when writing custom views.

Summary

Inherited XML attributes

From class android.widget.ImageView
From class android.view.View

Inherited constants

From class android.view.View

Inherited fields

From class android.view.View

Public constructors

AppCompatImageButton(Context context)
AppCompatImageButton(Context context, AttributeSet attrs)
AppCompatImageButton(Context context, AttributeSet attrs, int defStyleAttr)

Public methods

boolean hasOverlappingRendering()

Returns whether this View has content which overlaps.

void setBackgroundDrawable(Drawable background)

This method is deprecated. use setBackground(Drawable) instead

void setBackgroundResource(int resId)

Set the background to a given resource.

void setImageResource(int resId)

Sets a drawable as the content of this ImageView.

Protected methods

void drawableStateChanged()

This function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown.

Inherited methods

From class android.widget.ImageButton
From class android.widget.ImageView
From class android.view.View
From class java.lang.Object
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.accessibility.AccessibilityEventSource
From interface android.support.v4.view.TintableBackgroundView

Public constructors

AppCompatImageButton

AppCompatImageButton (Context context)

Parameters
context Context

AppCompatImageButton

AppCompatImageButton (Context context, 
                AttributeSet attrs)

Parameters
context Context
attrs AttributeSet

AppCompatImageButton

AppCompatImageButton (Context context, 
                AttributeSet attrs, 
                int defStyleAttr)

Parameters
context Context
attrs AttributeSet
defStyleAttr int

Public methods

hasOverlappingRendering

boolean hasOverlappingRendering ()

Returns whether this View has content which overlaps.

This function, intended to be overridden by specific View types, is an optimization when alpha is set on a view. If rendering overlaps in a view with alpha < 1, that view is drawn to an offscreen buffer and then composited into place, which can be expensive. If the view has no overlapping rendering, the view can draw each primitive with the appropriate alpha value directly. An example of overlapping rendering is a TextView with a background image, such as a Button. An example of non-overlapping rendering is a TextView with no background, or an ImageView with only the foreground image. The default implementation returns true; subclasses should override if they have cases which can be optimized.

The current implementation of the saveLayer and saveLayerAlpha methods in Canvas necessitates that a View return true if it uses the methods internally without passing the CLIP_TO_LAYER_SAVE_FLAG.

Note: The return value of this method is ignored if forceHasOverlappingRendering(boolean) has been called on this view.

Returns
boolean true if the content in this view might overlap, false otherwise.

setBackgroundDrawable

void setBackgroundDrawable (Drawable background)

This method is deprecated.
use setBackground(Drawable) instead

Parameters
background Drawable

setBackgroundResource

void setBackgroundResource (int resId)

Set the background to a given resource. The resource should refer to a Drawable object or 0 to remove the background.

Parameters
resId int: The identifier of the resource.

setImageResource

void setImageResource (int resId)

Sets a drawable as the content of this ImageView.

This does Bitmap reading and decoding on the UI thread, which can cause a latency hiccup. If that's a concern, consider using setImageDrawable(android.graphics.drawable.Drawable) or setImageBitmap(android.graphics.Bitmap) and BitmapFactory instead.

Parameters
resId int: the resource identifier of the drawable

Protected methods

drawableStateChanged

void drawableStateChanged ()

This function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown.

If the View has a StateListAnimator, it will also be called to run necessary state change animations.

Be sure to call through to the superclass when overriding this function.

Hooray!