Android Beginner to create a simple user interface

Source: Internet
Author: User

Learn reprint from the place: http://hukai.me/android-training-course-in-chinese/basics/firstapp/building-ui.html, if there is infringement please tell me, I immediately delete

The first step: Create a new project using Android Studio, with the following directory

Step two: Punch in the Activity_my.xml file, modify the contents of the file

Modify the String.xml file

After modifying the design page display effect:

Android:orientation: This property sets the placement direction of the control, horizontal represents horizontal placement, and vertical represents portrait placement;

Wrap_content: automatic stretching according to content;

Match_parent: Mandatory to extend the view to the parent element size;

As shown, this setting is appropriate for the button, but not good for the text box, because the user may enter a longer content, so that the text box fills the full width of the button,

LinearLayout Use the weight attribute to achieve this purpose, so you can modify the text box's android:layout_weight to set, Android for all view default weight is 0, such as

If only one view is set to a weight greater than 0, the view occupies all the remaining space to remove the space occupied by the other view itself. The weight of the edittext is therefore set to 1 so that it can account for

All the space except the button.

Modify the following:

For example, the whole line is full after the modification

Android Beginner to create a simple user interface

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.