Reputation: 19
In a recent code review, my reviewer kept asking me to keep the layout changes within its respective layout xml, but for some reason changing the xml attributes doesn't visibly register on UI of the app. So instead I've been finding references to the respective views and .setTextColor (etc) on them.
I was wondering if there were any short-comings/flaws to my approach, be it run-time issues, design issues, etc.
Upvotes: 1
Views: 32
Reputation: 1093
Yes there are gains when you declare UI attributes in layout xml file, first thing is maintainability of code, it is more cleaner when you keep maximum UI code in layout.xml, In case of performance - View attributes are pulled into the constructor of the view when inflated from layout.xml fie, So default values are over ridden with the values provided in layout at the point of creation of the view, If changes are made after View object creation, View will have to be invalidated again for changes to take effect, performance implications can vary according to the methods you call on the views after object creation(that is xml inflation )
Upvotes: 1