I would prefer to do most UI layout and set view properties in XML but have run into times when I need to override these values in code before rendering the view.
I can continue to do this after the layout/viewgroup has been constructed from the processed XML files but am wondering if there is a better way.
I know which property values need to be overwritten before the UI is constructed. Is there an event / pipeline I can extent that would allow me to inject a new value for a property while it is being constructed by the system?
Not sure if this more efficient – just thinking about alternative solutions.
Thanks.
If such a pipeline exists (I don’t think it does) it will probably not gain you more in terms of efficiency.
When you compile your application, each XML layout file is compiled into a View resource, which are loaded from your application code (mostly in the
onCreate()method of Activity).This basically means after compiling, there’s no XML to be edited/injected.