# CompoundButtonCompat

# CompoundButtonCompat

Artifact:[androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core)  
[View Source](https://cs.android.com/search?q=file:androidx/core/widget/CompoundButtonCompat.java+class:androidx.core.widget.CompoundButtonCompat)  
Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/core/widget/CompoundButtonCompat "View this page in Java")

<br />

```
class CompoundButtonCompat
```

<br />

*** ** * ** ***

Helper for accessing[CompoundButton](https://developer.android.com/reference/android/widget/CompoundButton.html).

## Summary

|                                                ### Public functions                                                |
|--------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `java-static `[Drawable](https://developer.android.com/reference/android/graphics/drawable/Drawable.html)`?`       | [getButtonDrawable](https://developer.android.com/reference/kotlin/androidx/core/widget/CompoundButtonCompat#getButtonDrawable(android.widget.CompoundButton))`(button: `[CompoundButton](https://developer.android.com/reference/android/widget/CompoundButton.html)`)` Returns the drawable used as the compound button image                                                                                                                                                                                                                                                                                                                                                                                    |
| `java-static `[ColorStateList](https://developer.android.com/reference/android/content/res/ColorStateList.html)`?` | [getButtonTintList](https://developer.android.com/reference/kotlin/androidx/core/widget/CompoundButtonCompat#getButtonTintList(android.widget.CompoundButton))`(button: `[CompoundButton](https://developer.android.com/reference/android/widget/CompoundButton.html)`)` Returns the tint applied to the button drawable                                                                                                                                                                                                                                                                                                                                                                                           |
| `java-static `[PorterDuff.Mode](https://developer.android.com/reference/android/graphics/PorterDuff.Mode.html)`?`  | [getButtonTintMode](https://developer.android.com/reference/kotlin/androidx/core/widget/CompoundButtonCompat#getButtonTintMode(android.widget.CompoundButton))`(button: `[CompoundButton](https://developer.android.com/reference/android/widget/CompoundButton.html)`)` name android:buttonTintMode                                                                                                                                                                                                                                                                                                                                                                                                               |
| `java-static `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                        | [setButtonTintList](https://developer.android.com/reference/kotlin/androidx/core/widget/CompoundButtonCompat#setButtonTintList(android.widget.CompoundButton,android.content.res.ColorStateList))`(button: `[CompoundButton](https://developer.android.com/reference/android/widget/CompoundButton.html)`, tint: `[ColorStateList](https://developer.android.com/reference/android/content/res/ColorStateList.html)`?)` Applies a tint to the button drawable.                                                                                                                                                                                                                                                     |
| `java-static `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                        | [setButtonTintMode](https://developer.android.com/reference/kotlin/androidx/core/widget/CompoundButtonCompat#setButtonTintMode(android.widget.CompoundButton,android.graphics.PorterDuff.Mode))`(button: `[CompoundButton](https://developer.android.com/reference/android/widget/CompoundButton.html)`, tintMode: `[PorterDuff.Mode](https://developer.android.com/reference/android/graphics/PorterDuff.Mode.html)`?)` Specifies the blending mode used to apply the tint specified by[setButtonTintList](https://developer.android.com/reference/kotlin/androidx/core/widget/CompoundButtonCompat#setButtonTintList(android.widget.CompoundButton,android.content.res.ColorStateList))} to the button drawable. |

## Public functions

### getButtonDrawable

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
java-static fun getButtonDrawable(button: CompoundButton): Drawable?
```

Returns the drawable used as the compound button image  

|                                                                       See also                                                                        |
|-------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [setButtonDrawable](https://developer.android.com/reference/android/widget/CompoundButton.html#setButtonDrawable(android.graphics.drawable.Drawable)) |   |

### getButtonTintList

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
java-static fun getButtonTintList(button: CompoundButton): ColorStateList?
```

Returns the tint applied to the button drawable  

|                                                                                             See also                                                                                              |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [setButtonTintList](https://developer.android.com/reference/kotlin/androidx/core/widget/CompoundButtonCompat#setButtonTintList(android.widget.CompoundButton,android.content.res.ColorStateList)) |   |

### getButtonTintMode

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
java-static fun getButtonTintMode(button: CompoundButton): PorterDuff.Mode?
```

name android:buttonTintMode  

|                                               Returns                                               |
|-----------------------------------------------------------------------------------------------------|-----------------------------------------------------------------|
| [PorterDuff.Mode](https://developer.android.com/reference/android/graphics/PorterDuff.Mode.html)`?` | the blending mode used to apply the tint to the button drawable |

|                                                                                            See also                                                                                             |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [setButtonTintMode](https://developer.android.com/reference/kotlin/androidx/core/widget/CompoundButtonCompat#setButtonTintMode(android.widget.CompoundButton,android.graphics.PorterDuff.Mode)) |   |

### setButtonTintList

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
java-static fun setButtonTintList(button: CompoundButton, tint: ColorStateList?): Unit
```

Applies a tint to the button drawable. Does not modify the current tint mode, which is[SRC_IN](https://developer.android.com/reference/android/graphics/PorterDuff.Mode.html#SRC_IN)by default.

Subsequent calls to[setButtonDrawable](https://developer.android.com/reference/android/widget/CompoundButton.html#setButtonDrawable(android.graphics.drawable.Drawable))should automatically mutate the drawable and apply the specified tint and tint mode using[setTintList](https://developer.android.com/reference/kotlin/androidx/core/graphics/drawable/DrawableCompat#setTintList(android.graphics.drawable.Drawable,android.content.res.ColorStateList)).  

|                                                  Parameters                                                  |
|--------------------------------------------------------------------------------------------------------------|----------------------------------------------|
| `button: `[CompoundButton](https://developer.android.com/reference/android/widget/CompoundButton.html)       | button for which to apply the tint.          |
| `tint: `[ColorStateList](https://developer.android.com/reference/android/content/res/ColorStateList.html)`?` | the tint to apply, may be`null`to clear tint |

|                                                                                             See also                                                                                              |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [setButtonTintList](https://developer.android.com/reference/kotlin/androidx/core/widget/CompoundButtonCompat#setButtonTintList(android.widget.CompoundButton,android.content.res.ColorStateList)) |   |

### setButtonTintMode

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
java-static fun setButtonTintMode(button: CompoundButton, tintMode: PorterDuff.Mode?): Unit
```

Specifies the blending mode used to apply the tint specified by[setButtonTintList](https://developer.android.com/reference/kotlin/androidx/core/widget/CompoundButtonCompat#setButtonTintList(android.widget.CompoundButton,android.content.res.ColorStateList))} to the button drawable. The default mode is[SRC_IN](https://developer.android.com/reference/android/graphics/PorterDuff.Mode.html#SRC_IN).  

|                                                   Parameters                                                    |
|-----------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------|
| `button: `[CompoundButton](https://developer.android.com/reference/android/widget/CompoundButton.html)          | button for which to apply the tint mode.                            |
| `tintMode: `[PorterDuff.Mode](https://developer.android.com/reference/android/graphics/PorterDuff.Mode.html)`?` | the blending mode used to apply the tint, may be`null`to clear tint |

|                                                                                           See also                                                                                            |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [getButtonTintMode](https://developer.android.com/reference/kotlin/androidx/core/widget/CompoundButtonCompat#getButtonTintMode(android.widget.CompoundButton))                                |   |
| [setTintMode](https://developer.android.com/reference/kotlin/androidx/core/graphics/drawable/DrawableCompat#setTintMode(android.graphics.drawable.Drawable,android.graphics.PorterDuff.Mode)) |   |