Android xml vs java layouts performance

后端 未结 3 884
甜味超标
甜味超标 2020-11-28 10:51

Android SDK offers to developers to write layouts in xml files or directly in java code. I have read about it and everyone says that xml are easier to maintain and simplyer

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-28 11:14

    One primary factor to decide where to declare a UI component is it's behavior during the app life cycle. If it's static I'd declare all attributes needed in XML, if it changes according to the user interaction I'd have to implement it in the activity.

    I would go for XML as much as possible for the benefits mentions above like coherence, better management for various screen sizes, localization, resource management etc.,

提交回复
热议问题