CompoundButtonCompat

Added in 1.1.0

public final class CompoundButtonCompat


Helper for accessing CompoundButton.

Summary

Public methods

static @Nullable Drawable

Returns the drawable used as the compound button image

static @Nullable ColorStateList

Returns the tint applied to the button drawable

static @Nullable PorterDuff.Mode

name android:buttonTintMode

static void

Applies a tint to the button drawable.

static void
setButtonTintMode(
    @NonNull CompoundButton button,
    @Nullable PorterDuff.Mode tintMode
)

Specifies the blending mode used to apply the tint specified by setButtonTintList} to the button drawable.

Public methods

getButtonDrawable

Added in 1.1.0
public static @Nullable Drawable getButtonDrawable(@NonNull CompoundButton button)

Returns the drawable used as the compound button image

getButtonTintList

Added in 1.1.0
public static @Nullable ColorStateList getButtonTintList(@NonNull CompoundButton button)

Returns the tint applied to the button drawable

getButtonTintMode

Added in 1.1.0
public static @Nullable PorterDuff.Mode getButtonTintMode(@NonNull CompoundButton button)

name android:buttonTintMode

Returns
@Nullable PorterDuff.Mode

the blending mode used to apply the tint to the button drawable

setButtonTintList

Added in 1.1.0
public static void setButtonTintList(
    @NonNull CompoundButton button,
    @Nullable 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 should automatically mutate the drawable and apply the specified tint and tint mode using setTintList.

Parameters
@NonNull CompoundButton button

button for which to apply the tint.

@Nullable ColorStateList tint

the tint to apply, may be null to clear tint

setButtonTintMode

Added in 1.1.0
public static void setButtonTintMode(
    @NonNull CompoundButton button,
    @Nullable PorterDuff.Mode tintMode
)

Specifies the blending mode used to apply the tint specified by setButtonTintList} to the button drawable. The default mode is SRC_IN.

Parameters
@NonNull CompoundButton button

button for which to apply the tint mode.

@Nullable PorterDuff.Mode tintMode

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