How to set a different theme to a Layout
This is now possible by using the android:theme
property on the view and setting it to any theme you like. Note that the child views will inherit the theme of their parent.
You can use ContextThemeWrapper()
to apply theme when create layout programmatically.
LinearLayout darkThemeLayout = new LinearLayout(new ContextThemeWrapper(context, R.style.DarkTheme));