ContextThemeWrapper
class ContextThemeWrapper : ContextWrapper
| kotlin.Any | |||
| ↳ | android.content.Context | ||
| ↳ | android.content.ContextWrapper | ||
| ↳ | androidx.appcompat.view.ContextThemeWrapper |
A context wrapper that allows you to modify or replace the theme of the wrapped context.
Summary
Public constructors |
|---|
|
Creates a new context wrapper with no theme and no base context. |
ContextThemeWrapper(base: Context!, themeResId: @StyleRes Int)Creates a new context wrapper with the specified theme. |
ContextThemeWrapper(base: Context!, theme: Resources.Theme!)Creates a new context wrapper with the specified theme. |
Public functions |
|
|---|---|
Unit |
applyOverrideConfiguration(overrideConfiguration: Configuration!)Call to set an "override configuration" on this context -- this is a configuration that replies one or more values of the standard configuration that is applied to the context. |
AssetManager! |
|
Resources! |
|
Any! |
getSystemService(name: String!) |
Resources.Theme! |
getTheme() |
Int |
Returns the resource ID of the theme that is to be applied on top of the base context's theme. |
Unit |
Protected functions |
|
|---|---|
Unit |
attachBaseContext(newBase: Context!) |
Unit |
onApplyThemeResource(theme: Resources.Theme!, resid: Int, first: Boolean)Called by setTheme and getTheme to apply a theme resource to the current Theme object. |
Inherited Constants |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Public constructors
ContextThemeWrapper
ContextThemeWrapper()
Creates a new context wrapper with no theme and no base context.
Note: A base context must be attached using attachBaseContext before calling any other method on the newly constructed context wrapper.
ContextThemeWrapper
ContextThemeWrapper(base: Context!, themeResId: @StyleRes Int)
Creates a new context wrapper with the specified theme.
The specified theme will be applied on top of the base context's theme. Any attributes not explicitly defined in the theme identified by themeResId will retain their original values.
ContextThemeWrapper
ContextThemeWrapper(base: Context!, theme: Resources.Theme!)
Creates a new context wrapper with the specified theme.
Unlike ContextThemeWrapper, the theme passed to this constructor will completely replace the base context's theme.
| Parameters | |
|---|---|
base: Context! |
the base context |
theme: Resources.Theme! |
the theme against which resources should be inflated |
Public functions
applyOverrideConfiguration
fun applyOverrideConfiguration(overrideConfiguration: Configuration!): Unit
Call to set an "override configuration" on this context -- this is a configuration that replies one or more values of the standard configuration that is applied to the context. See createConfigurationContext for more information.
This method can only be called once, and must be called before any calls to getResources or getAssets are made.
getThemeResId
fun getThemeResId(): Int
Returns the resource ID of the theme that is to be applied on top of the base context's theme.
Protected functions
onApplyThemeResource
protected fun onApplyThemeResource(theme: Resources.Theme!, resid: Int, first: Boolean): Unit
Called by setTheme and getTheme to apply a theme resource to the current Theme object. Can override to change the default (simple) behavior. This method will not be called in multiple threads simultaneously.
| Parameters | |
|---|---|
theme: Resources.Theme! |
The Theme object being modified. |
resid: Int |
The theme style resource being applied to theme. |
first: Boolean |
Set to true if this is the first time a style is being applied to theme. |