Lab 4
Lab 4
Note
• No need to specify layout_height and layout_width for the
GridLayout child views as they default to WRAP_CONTENT .
Anchoring Controls
• For anchoring controls relative to the four edges of the screen, we use
a RelativeLayout container.
• Defining Layout for Each Mode
• In this method, we define two layouts. One arranges the controls in the
default portrait mode, and the other arranges the controls in landscape
mode.
• If we see the code of Relative layout shows five Button controls
arranged in a RelativeLayout container
• When the application is run while in the default portrait mode, the controls
appear as shown in Figure (Left). The xml code of the figure left is already present
in relative layout slide.
• To switch between portrait mode and landscape mode on the device emulator,
press the Ctrl+F11 keys
•
Defining Layout for Each Mode
• In this method, we define two layouts. One arranges the controls in
the default portrait mode, and the other arranges the controls in
landscape mode.
• The code of previous slide is shown below.
• The Landscape and patriot mode is shown
Task on Linear Layout
XML code
Task on Relative Layout
XML Code