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 attrs: AttributeSet, @AttrRes defStyleAttr: Int, @StyleRes defStyleRes: Int): Context
Uses the materialThemeOverlay attribute to create a themed context.