MaterialThemeOverlay

Utility to apply a theme overlay to any android.content.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);
}

Functions

Link copied to clipboard
open fun wrap(@NonNull context: Context, @Nullable set: AttributeSet, @AttrRes defStyleAttr: Int, @StyleRes defStyleRes: Int): Context
Uses the materialThemeOverlay attribute to create a themed context.
open fun wrap(@NonNull context: Context, @Nullable set: AttributeSet, @AttrRes defStyleAttr: Int, @StyleRes defStyleRes: Int, @NonNull optionalAttrs: Array<Int>): Context
Uses the materialThemeOverlay attribute and optionalAttr attributes to create a combined themed context.