Friday, 6 May 2016

Android Layouts

There are six different layouts in android:
1. Linear Layout: Aligns all children in a single direction, vertically or horizontally.
2. Relative Layout: Displays child views in relative positions.
3. Table Layout: This groups the views into rows and columns.
4. Grid View: Displays data in a 2D, scrollable grid.
5. Tab Layout: This provides a horizontal view to display all the tabs.
6. List View: List of scrollable items.
You can declare a layout in two ways:
1. Declare UI elements in XML
2. Instantiate layout elements at runtime.
Layout Parameters:
XML layout attributes named layout_something define layout parameters for the View that are appropriate for the ViewGroup in which it resides.
A view has a location, expressed as a pair of left and top coordinates, and two dimensions, expressed as a width and a height. The unit for location and dimensions is the pixel.
Layout Files: Each layout file must contain at least one root element. The root element must be either a View or ViewGroup object. Once defined, other widgets or additional objects can be added as objects.
• Attributes: Each layout has its own variety of XML attributes. Attributes need to be declared first through "attr" tag in the /res/values sub directory.

No comments:

Post a Comment