How to set different themes for a bloated layout as a stub

I have a layout that I am inflating in the ViewStub. When it is inside view A, I want to have one set of styles applied to EditText fields, and when it is in view B, I want to have another set of styles applied to EditText fields.

Firstly, is it possible, and secondly (if so), how would I do it?

+7
android
source share
1 answer

I'm not sure about ViewStubs specifically, but if you want to inflate a predefined layout and add it to the ViewGroup, you can use ContextThemeWrapper .

View viewOne = View.inflate(new ContextThemeWrapper(context, R.style.Theme_One), R.layout.my_layout) View viewTwo = View.inflate(new ContextThemeWrapper(context, R.style.Theme_Two), R.layout.my_layout) 
+13
source share

All Articles