Android APIs
public final class

CompoundButtonCompat

extends Object
java.lang.Object
   ↳ android.support.v4.widget.CompoundButtonCompat

Class Overview

Helper for accessing CompoundButton methods introduced after API level 4 in a backwards compatible fashion.

Summary

XML Attributes
Attribute Name Related Method Description
android:buttonTintMode getButtonTintMode(CompoundButton) Blending mode used to apply the button graphic tint. 
Public Methods
static Drawable getButtonDrawable(CompoundButton button)
Returns the drawable used as the compound button image
static ColorStateList getButtonTintList(CompoundButton button)
Returns the tint applied to the button drawable
static PorterDuff.Mode getButtonTintMode(CompoundButton button)
static void setButtonTintList(CompoundButton button, ColorStateList tint)
Applies a tint to the button drawable.
static void setButtonTintMode(CompoundButton button, PorterDuff.Mode tintMode)
Specifies the blending mode used to apply the tint specified by setButtonTintList(CompoundButton, ColorStateList)} to the button drawable.
[Expand]
Inherited Methods
From class java.lang.Object

XML Attributes

android:buttonTintMode

Blending mode used to apply the button graphic tint.

Must be one of the following constant values.

ConstantValueDescription
src_over3 The tint is drawn on top of the drawable. [Sa + (1 - Sa)*Da, Rc = Sc + (1 - Sa)*Dc]
src_in5 The tint is masked by the alpha channel of the drawable. The drawable’s color channels are thrown out. [Sa * Da, Sc * Da]
src_atop9 The tint is drawn above the drawable, but with the drawable’s alpha channel masking the result. [Da, Sc * Da + (1 - Sa) * Dc]
multiply14 Multiplies the color and alpha channels of the drawable with those of the tint. [Sa * Da, Sc * Dc]
screen15 [Sa + Da - Sa * Da, Sc + Dc - Sc * Dc]
add16 Combines the tint and drawable color and alpha channels, clamping the result to valid color values. Saturate(S + D)

This corresponds to the global attribute resource symbol buttonTintMode.

Public Methods

public static Drawable getButtonDrawable (CompoundButton button)

Returns the drawable used as the compound button image

public static ColorStateList getButtonTintList (CompoundButton button)

Returns the tint applied to the button drawable

public static PorterDuff.Mode getButtonTintMode (CompoundButton button)

Related XML Attributes
Returns
  • the blending mode used to apply the tint to the button drawable

public static void setButtonTintList (CompoundButton button, ColorStateList tint)

Applies a tint to the button drawable. Does not modify the current tint mode, which is SRC_IN by default.

Subsequent calls to setButtonDrawable(Drawable) should automatically mutate the drawable and apply the specified tint and tint mode using setTintList(Drawable, ColorStateList).

Parameters
tint the tint to apply, may be null to clear tint

public static void setButtonTintMode (CompoundButton button, PorterDuff.Mode tintMode)

Specifies the blending mode used to apply the tint specified by setButtonTintList(CompoundButton, ColorStateList)} to the button drawable. The default mode is SRC_IN.

Parameters
tintMode the blending mode used to apply the tint, may be null to clear tint