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

CompoundButtonCompat

class CompoundButtonCompat
kotlin.Any
   ↳ androidx.core.widget.CompoundButtonCompat

Helper for accessing android.widget.CompoundButton.

Summary

Public methods

static Drawable?

Returns the drawable used as the compound button image

static ColorStateList?

Returns the tint applied to the button drawable

static Mode?

static Unit
setButtonTintList(@NonNull button: CompoundButton, @Nullable tint: ColorStateList?)

Applies a tint to the button drawable.

static Unit
setButtonTintMode(@NonNull button: CompoundButton, @Nullable tintMode: Mode?)

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

Public methods

getButtonDrawable

@Nullable static fun getButtonDrawable(@NonNull button: CompoundButton): Drawable?

Returns the drawable used as the compound button image

getButtonTintList

@Nullable static fun getButtonTintList(@NonNull button: CompoundButton): ColorStateList?

Returns the tint applied to the button drawable

getButtonTintMode

@Nullable static fun getButtonTintMode(@NonNull button: CompoundButton): Mode?
Return
Mode?: the blending mode used to apply the tint to the button drawable

setButtonTintList

static fun setButtonTintList(@NonNull button: CompoundButton, @Nullable tint: ColorStateList?): Unit

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

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

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

setButtonTintMode

static fun setButtonTintMode(@NonNull button: CompoundButton, @Nullable tintMode: Mode?): Unit

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

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