Brief Introduction to Android Layout

Source: Internet
Author: User

First of all, I will not talk about linearlayout, scrollview... and other layout S. I 'd like to briefly describe the landscape and landscape screens.

We may encounter some problems, such as the small Q unit converter I mentioned earlier. I don't know if anyone can try it. Let's try it. My main. XML is written in this way.

<? XML version = "1.0" encoding = "UTF-8"?> <Br/> <linearlayout xmlns: Android = "http://schemas.android.com/apk/res/android" <br/> Android: Id = "@ + ID/ad_container" <br/> Android: orientation = "vertical" <br/> Android: layout_width = "fill_parent" <br/> Android: layout_height = "wrap_content"> <br/> <textview <br/> Android: id = "@ + ID/Item1" <br/> Android: layout_width = "fill_parent" <br/> Android: layout_height = "wrap_content" <br/> <edittext <br/> Android: Id = "@ + ID/edittext1" <br/> Android: layout_width = "fill_parent" <br/> Android: layout_height = "wrap_content" <br/> Android: Numeric = "decimal" Android: TEXT = ""/> <br/> <textview <br/> Android: Id = "@ + ID/item2" <br/> Android: layout_width = "fill_parent" <br/> Android: layout_height = "wrap_content" <br/> <edittext <br/> Android: id = "@ + ID/edittext2" <br/> Android: layout_width = "fill_parent" <br/> Android: layout_height = "wrap_content" <br/> Android: numeric = "decimal" <br/> Android: text = ""/> <br/> <textview <br/> Android: id = "@ + ID/item3" <br/> Android: layout_width = "fill_parent" <br/> Android: layout_height = "wrap_content" <br/> <edittext <br/> Android: Id = "@ + ID/edittext3" <br/> Android: layout_width = "fill_parent" <br/> Android: layout_height = "wrap_content" <br/> Android: Numeric = "decimal" <br/> Android: TEXT = ""/> <br/> <button <br/> Android: Id = "@ + ID/Change" <br/> Android: layout_width = "fill_parent" <br/> Android: layout_height = "wrap_content" <br/> Android: TEXT = "Conversion"/> <br/> <spinner <br/> Android: Id = "@ + ID/choice" <br/> Android: layout_width = "fill_parent" <br/> Android: layout_height = "wrap_content"/> <br/> </linearlayout>

After writing the code, run the program and obtain the interface as follows:

Some people have said, it's okay, except for the ugly ones. Isn't that okay? Don't worry, just press Ctrl + F12 (it's enough for the real machine to go straight over ?) Found? Is there a problem?

 

At this time, we can see that the spinner component cannot be displayed very well. Of course, I can also click the mouse, finger? I'm not sure.

Many Android development books in China did not explain this knowledge. Finally, they found a solution in a very thin and powerful book: add a layout-land folder under the res folder (note that the suffix is-land) and add main. XML and then re-layout, that is, design a layout that can be normally displayed on a horizontal screen.

The new layout code is as follows:

<? Xml version = "1.0" encoding = "UTF-8"?> <Br/> <LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android" <br/> android: orientation = "vertical" <br/> android: layout_width = "fill_parent" <br/> android: layout_height = "wrap_content"> <br/> <LinearLayout <br/> android: orientation = "horizontal" <br/> android: layout_width = "fill_parent" <br/> android: layout_height = "wrap_content" <br/> <TextView <br/> android: id = "@ + id/item1" <br/> android: layout_width = "wrap_content" <br/> android: layout_height = "wrap_content" <br/> <EditText <br/> android: id = "@ + id/edittext1" <br/> android: layout_width = "fill_parent" <br/> android: layout_height = "wrap_content" <br/> android: numeric = "decimal" <br/> </LinearLayout> </p> <LinearLayout <br/> android: orientation = "horizontal" <br/> android: layout_width = "fill_parent" <br/> android: layout_height = "wrap_content"> <br/> <TextView <br/> android: id = "@ + id/item2" <br/> android: layout_width = "wrap_content" <br/> android: layout_height = "wrap_content" <br/> <EditText <br/> android: id = "@ + id/edittext2" <br/> android: layout_width = "fill_parent" <br/> android: layout_height = "wrap_content" <br/> android: numeric = "decimal" <br/> </LinearLayout> <br/> <LinearLayout <br/> android: orientation = "horizontal" <br/> android: layout_width = "fill_parent" <br/> android: layout_height = "wrap_content"> <br/> <TextView <br/> android: id = "@ + id/item3" <br/> android: layout_width = "wrap_content" <br/> android: layout_height = "wrap_content" <br/> <EditText <br/> android: id = "@ + id/edittext3" <br/> android: layout_width = "fill_parent" <br/> android: layout_height = "wrap_content" <br/> android: numeric = "decimal" <br/> </LinearLayout> <br/> <LinearLayout <br/> android: orientation = "horizontal" <br/> android: layout_width = "fill_parent" <br/> android: layout_height = "wrap_content"> <br/> <Button <br/> android: id = "@ + id/change" <br/> android: layout_width = "wrap_content" <br/> android: layout_height = "wrap_content" <br/> <Spinner <br/> android: id = "@ + id/Choice" <br/> android: layout_width = "fill_parent" <br/> android: layout_height = "wrap_content" <br/> </LinearLayout>

Let's run it again:

As we can see, now we can put down all the original components, and the interface is not very ugly. I did not add any text or images, so I still want to design it a little bit. Of course, I am just doing an example. There are many solutions. Please use your creativity! Remember that the suffix is-land ......

 

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.