Dynamic Layout Design


Android activity contains various user interface components e.g Button, Radio button, List, Text field etc. The user interface component can be  arranged/attached with the activity in two different ways.

Declaring UI element in layout file
Basically, Layout file is xml formatted file present in res/layout. In this file, tags are used to define any UI component and properties are used to configure the components. It is similar to HTML tags. This style is preferred because UI related codes and business logic codes are separated. It is comparatively easier to manage.

Creating view element at runtime
UI Component can be created programmatically. UI component class setter methods help to configure the component. This style is not recommended unless it’s really required. In this style, business logic gets mixed with the component UI code. It doesn’t look neat and sometimes it’s hard to manage.



Leave a Reply