Five layouts and logcat print logs in Android

Source: Internet
Author: User

There are five categories of layouts in Android, sometimes you might use one, but sometimes you may need two or three layouts together. These five layouts are: linearlayout (linear layout), Framelayout (frame layout), relativelayout (relative layout), tablelayout (table layout), absolutelayout (coordinate layout);

LinearLayout: is called linear layout, divided into horizontal and vertical, set vertical or horizontal attribute values, to arrange all the child elements. All child elements are stacked behind other elements, so that each row of a vertical list will have only one element, no matter how wide they are, and a horizontal list will have only one row high (height is the height of the highest child element plus the border height). LinearLayout keeps the spacing between child elements and aligns with each other (right-aligned, Middle-aligned, or left-aligned relative to an element).

Framelayout: Called a frame layout, pre-reserved spaces in the screen, after which you can populate a single object. For example, a picture you want to publish. All child elements will be pinned to the upper-left corner of the screen; You cannot specify a location for a child element in Framelayout. The latter child element will overwrite the padding directly above the previous child element, blocking them partially or completely (unless the latter element is transparent).

Relativelayout: Relative layout, you can specify the position of an element relative to other elements, by layout_below= the relative control. You can arrange two elements in a right-aligned, or up-down, or center-of-the-screen form. Elements are arranged sequentially, so if the first element is in the center of the screen, then the other elements relative to the element are arranged in the relative position of the center of the screen. If you use XML to specify this layout, the associated element must be defined before you can define it.

Tablelayout: A table layout that assigns the position of a child element to a row or column. A tablelayout is made up of many TableRow, and each TableRow defines a row (in fact, you can define other sub-objects, as explained below). The Tablelayout container does not display the row, cloumns, or cell border lines. Each row has 0 or more cells, and each cell has a view object. A table consists of columns and rows that make up many cells. Table allows cells to be empty. Cells cannot span columns, which is not the same as in HTML.

Absolutelayout: Coordinate layout, you set the corresponding control through x, y coordinates, (0, 0) is the upper left corner, when moving down or to the right, the coordinate value will be larger. Absolutelayout does not have a page border, allowing elements to overlap each other (although not recommended). We don't usually recommend using absolutelayout unless you have a legitimate reason to use it because it makes the interface code too rigid to work well on different devices.

Logcat can display the print of the log:

LOG.V ()--------------------verboselog.d ()--------------------debuglog.i ()--------------------INFOLOG.W () --------------------warnlog.e ()--------------------error above log level in turn, the debug information should only exist in the development, info, WARN, Error these three types of logs will appear in the release version. For Java classes, you can declare a string constant Tag,logcat can distinguish between different logs according to him, generally set the tag to the class name

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.