Android layout full demo

Source: Internet
Author: User

A good application is not only functional, but also takes some effort on the interface. The better the design, the better the user experience, or the better the animation. to understand the layout, you must know the five major la s:

Linearlayout, relativelayout, framelayout, absolutelayout, and tablelayout)


Currently, the first two are used at most: Linear and relative layout. The former feature is that it organizes controls in a vertical or horizontal form. When the layout direction is set to vertical, all child controls in the layout are organized in the same column. When the layout direction is set to normal, all child controls are organized in one row, the latter is characterized by adjustable orientation (left) and (horizontal and vertical) (right) alignment. The frame layout is a bit like a webpage, and no one is using the absolute layout currently. Table layout, as its name implies, uses a table to display the layout, but you cannot see the table. How to use the above layout skills. I made a demo ,:

 

How is this done? I can answer that you use relative layout, but the overall layout is linear. It is not written in the same layout. The second is separate writing. The advantage of separate writing is to reduceCode. So I created three la s, one at the top, the bottom, and the last on the main interface. Let's look at the code. The first is the header:

<Relativelayout xmlns: Android = "http://schemas.android.com/apk/res/android" Android: Orientation = "horizontal" Android: Background = "@ drawable/top" Android: layout_width = "fill_parent" Android: layout_height = "@ dimen/main_top"> <textview Android: text = "test" Android: layout_width = "fill_parent" Android: layout_height = "wrap_content" Android: gravity = "center_horizontal | center_vertical" Android: textsize = "19sp" Android: textcolor = "@ Android: color/background_dark" Android: layout_centervertical = "true" Android: layout_centerhorizontal = "true"> </textview> </relativelayout>

 

You can see that the header is relative to the namespace, the direction is horizontal, and the height is controlled within 40-50 dip. If you set wrap_content, you will find it very large, so you can narrow down the height. You only need the text below, even if you drag it in. Next is the bottom:

 
   
    
    
    
   

Like the header, three imageviews are thrown at the relative layout, and the width of 105dip is estimated, not accurate. In the left and right figures, you must have read the right code clearly. Finally, the main interface is:

 
<Linearlayout xmlns: Android = "http://schemas.android.com/apk/res/android" Android: Orientation = "vertical" Android: layout_width = "fill_parent" Android: layout_height = "fill_parent"> <! -- Use include to enclose the layout --> <include Android: layout_width = "wrap_content" Android: layout_height = "@ dimen/main_top" layout = "@ layout/main_top"/> <listview Android: layout_width = "fill_parent" Android: layout_height = "wrap_content" Android: layout_weight = "1" Android: Id = "@ + ID/listview" Android: cachecolorhint = "# ffffffff"> </listview> <include Android: layout_width = "wrap_content" Android: layout_height = "@ dimen/main_bottom" layout = "@ layout/main_bottom"/> </linearlayout>

The above shows a new thing, include. What is include? This means that you need to write a layout package to save the tedious code! The top is surrounded by include, which defines the width and height (required), and then "@ layout" is used to find the layout to be surrounded. Similarly, the bottom is also, the listview in the middle is understood by everyone. OK. This layout is introduced here.

This example source code in this: http://files.cnblogs.com/feifei1010/ListViewLayout.zip

You are welcome to join the Group for discussion with friends who love Android development ~~ Chengdu 252743807 Guangzhou 252743081

 

Related Article

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.