I want to use components in service when using WindowManager.addView but this is impossible now. Because components only use with Material theme.
Thanks!
Can you wrap the context you use to create the views in a ContextThemeWrapper with one of our
themes?
new ContextThemeWrapper(context, R.style.Theme_MaterialComponents)
Thank you! It worked fine!
val contextThemeWrapper = ContextThemeWrapper(this, R.style.Theme_MaterialComponents)
val inflater = LayoutInflater.from(contextThemeWrapper)
No problem! We do always want to use Themes. Since our components read attributes from there.
I found the useful article about usage ContextThemeWrapper
https://ataulm.github.io/2019/11/20/using-context-theme-wrapper.html
I'm trying to do this for an soft input (the service is an InputMethodService). The ContextThemeWrapper seems to be working, but only on some devices the background scrim is added. Do you have any clue why that is or what I could check to figure out what I'm doing wrong?
Most helpful comment
Thank you! It worked fine!