Tag Archives: Android

Android – Units

Written by . Filed under Apps. Tagged . No comments.

For measurements in the layouts

px number of real pixels. 100px is the same regardless of screen size.

In Inches - based on screen size. That is, it increases or decreases depending on the screen.

mm Millimeters - based on screen size. same as above.

pt points - 1 / 72 part of the above inch. It also increases or decreases depending on the  size of the screen.

dp Density Independent pixel - based on the physical density of the screen.
Assumes that a pixel is a pixel at 160dpi. However, it does not always make the size proportionally correct. You can also use dip.

sp Works like the dp but also takes into account the user’s font settings. This is recommended only to use on fonts.

Android – Layouts

Written by . Filed under Apps. Tagged . No comments.

A walkthrough to layout views in Android

FrameLayout

Its an layout for a single object an image for example. Children of an FrameLayout get automatically positioned at the top-left of the layout. This is not possible to change.
If there are more than one child there will be only one visible, the first.

LinearLayout

The most common view. This view has two modes to display its children – horizontal or vertical, one child per row or column if you think like a list (1 row)

TableLayout

As it sounds its a table of cell that you split the children into rows and columns. TableRow descripes the row and the biggest amount of children in a row sets the amount of total columns.

RelativeLayout

RelativeLayout lets the children be relative to each other, by declaring layoutabove=”id” or layoutbelow=”id” can you decide the position of the child, if you use both it will ly in between those two elements

Some attributes to consider that one can enter the on children
Note! Some layouts do not take into account all of the attributes.

Weight - the degree of importance as regards the filling of the parent. The higher the weight the more the right to place. Several children at the same weight are equally important. Logical but to consider is that if a child has two in weight and two children have a weight as a child entitled to 50% of the excess surface and two children will share the rest. Can be a little math if there are many children.

Margin - The distance between the child and nothing else.

Gravity - What the child should be adjusted to the row / column. Up, down, left, right, or a combination.

Padding - the distance between the child’s contents and the outer edge of the baby.