6

Can anybody briefly explain the advantages and disadvantages of dynamically modifying layouts as opposed to having static layouts? I faced this question in a quiz. Please explain your answer in detail. The following are True/False questions.

  • Dynamically-created layouts will appear on the screen and will respond noticeably faster than static layouts will.

  • Dynamically-created user interfaces can adapt to an application's runtime state, such as the amount of data that needs to be displayed at any one time.

  • Dynamic layouts can take advantage of contextual information that's not tracked by Android's configuration system (such as current location, usage time, or ambient light measurements).

  • Static layouts can't take advantage of contextual information, such as the device's orientation.

gary
  • 4,227
  • 3
  • 31
  • 58
Bruce
  • 8,609
  • 8
  • 54
  • 83
  • Can you explain what is your understanding of `static fragments`? This the first time I hear about this. Do you refer to fragments that are declared in XML file and not in code? – gunar Feb 10 '14 at 06:57
  • sry for my wording. i referred the fragments coded in xml file – Bruce Feb 10 '14 at 06:59
  • 1
    It seems like ur question is dynamic . – keshav Feb 10 '14 at 09:30

1 Answers1

11

The first statement is False because the idea of allowing static and dynamic layouts isn't to improve efficiency but to better seperete the view from the model/controller and to allow changes to the layout without recompiling the code. See here for more information: Android xml vs java layouts performance.

The second and third statements are True because this is information that can only be determined at runtime so to take advantage of that you would need to create some dynamic layout settings e.g. updating a position on a map, or updating the current weather for the area you are in.

The bottom statement is False because you can have layouts in XML files that are named specifically for the devices orientation e.g. layout-land.xml. Android will correctly pick this layout when the configuration is changed to landscape.

Remember that Android allows you to use both static and dynamic layouts but from what i've read most people opt for the static layout options where possible as this separation makes changes to the layout much easier. Dynamic vs XML layout in Android?

Good luck with the course, I believe i'm doing the same one.

Cheers,

Alexei Blue.

Community
  • 1
  • 1
Alexei Blue
  • 1,762
  • 3
  • 21
  • 36