Standard Layoutgalaxysupport



Layout

The rest of the answers are right, I want to add more explaination. The layoutgravity is about how to position the view in parent view. You must set gravity.after method parentView.addView. .Typical value tested under third-party laboratory condition. Typical value is the estimated average value considering the deviation in battery capacity among the battery samples tested under IEC 61960 standard. Actual battery life may vary depending on network environment, usage patterns and other factors.

Linear Layout Tutorial With Examples In Android

Linear layout is a simple layout used in android for layout designing. In the Linear layout all the elements are displayed in linear fashion means all the childs/elements of a linear layout are displayed according to its orientation. The value for orientation property can be either horizontal or vertical.

Table Of Contents

Types Of Linear Layout Orientation

There are two types of linear layout orientation:

  1. Vertical
  2. Horizontal

As the name specified these two orientations are used to arrange there child one after the other, in a line, either vertically or horizontally. Let’s we describe these in detail.

1.Vertical:

In this all the child are arranged vertically in a line one after the other. In below code snippets we have specified orientation “vertical” so the childs/views of this layout are displayed vertically.

2. Horizontal:

In this all the child are arranged horizontally in a line one after the other. In below code snippets we have specified orientation “horizontal” so the childs/views of this layout are displayed horizontally.

Important Note: All of the layout managers can be nested. This means that you can put a Relative Layout or Frame Layout as a child to Linear Layout.

Main Attributes In Linear Layout:

Now let’s we discuss about the attributes that helps us to configure a linear layout and its child controls. Some of the most important attributes you will use with linear layout include:

1. orientation: The orientation attribute used to set the childs/views horizontally or vertically. In Linear layout default orientation is vertical.

Example: Orientation vertical:

Example: Orientation Horizontal:

2. gravity:

Standard Layout Galaxy Support Desk

The gravity attribute is an optional attribute which is used to control the alignment of the layout like left, right, center, top, bottom etc.

Example: We have set gravity right for linear layout. So the buttons gets align from right side in Horizontal orientation.

3. layout_weight: The layout weight attribute specify each child control’s relative importance within the parent linear layout.

Example: weight property for button in linear layout. In the below example one button is of weight 2 and other is of weight 1.

In the layout image you can notice Button with weight 2 gets more size related the other.

4. weightSum: weightSum is the sum up of all the child attributes weight. This attribute is required if we define weight property of the childs.

Example: In the same above example of weight, we can define weightSum value 3.

Example of Linear Layout:

Now lets design 2 linear layout UI. First we have designed using weight attribute and second without using it. So below layout output will clear the difference between them:

Example 1:Layoutgalaxysupport First we will design Android Linear Layout without using weight property

In this example we have used one TextView and 4 Button. The orientation is set to vertical.

Below is the code of activity_main.xml

Standard Layout Galaxy Support Tool

Output Screen:

Example 2:

Standard Layout Galaxy Support App

In this example of linear layout we have used weight property.

Below is the code of activity_main.xml with explanation included

Standard Layout Galaxy Support Live Chat

Output Screen:


Continue Reading: