MaterialThemeOverlay
public
class
MaterialThemeOverlay
extends Object
java.lang.Object
|
↳ |
com.google.android.material.theme.overlay.MaterialThemeOverlay
|
Utility to apply a theme overlay to any Context
. The theme overlay is
read from an attribute in the style. This is useful to override theme attributes only for the
specific view.
The intended use is in a custom view constructor.
public MyCustomView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(wrap(context, attrs, defStyleAttr, DEF_STYLE_RES), attrs, defStyleAttr);
}
Summary
Public methods |
static
Context
|
wrap(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
Uses the materialThemeOverlay attribute to create a themed context.
|
Inherited methods |
From class
java.lang.Object
Object
|
clone()
|
boolean
|
equals(Object arg0)
|
void
|
finalize()
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
final
void
|
wait()
|
|
Public methods
wrap
public static Context wrap (Context context,
AttributeSet attrs,
int defStyleAttr,
int defStyleRes)
Uses the materialThemeOverlay attribute to create a themed context. This allows us to use
MaterialThemeOverlay with a default style, and gives us some protection against losing our
ThemeOverlay by clients who set android:theme or app:theme. If android:theme or app:theme is
specified by the client, any attributes defined there will take precedence over attributes
defined in materialThemeOverlay.
Parameters |
context |
Context |
attrs |
AttributeSet |
defStyleAttr |
int |
defStyleRes |
int |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[]]