wrapContextIfAvailable

open fun wrapContextIfAvailable(@NonNull context: Context, @NonNull colorContrastOptions: ColorContrastOptions): Context

Wraps the given context with the theme overlay where color resources are updated. The returned context can be used to create views with contrast support.

Note that this method does not guarantee the consistency of contrast throughout the app. If you want contrast to be updated automatically when a different contrast level is selected in the system, please use #applyToActivitiesIfAvailable(Application, ColorContrastOptions).

Parameters

context

The target context.

colorContrastOptions

The color contrast options object that specifies the theme overlay resource IDs for medium and high contrast mode.