Android Program Development 01

Source: Internet
Author: User

---restore content starts---

Create a simple user interface:

Android provides a range of XML tags for view and viewgroup subclasses to help us quickly get started with creating our own UI tags with XML

(Android's GUI consists mainly of multiple views (view) and multiple view groups (ViewGroup), where the main part of the view is widgets such as text boxes, buttons, etc. form controls , while ViewGroup is primarily comprised of invisible containers that define sub-views, such as the grid (GRID) vertical list part (verticallist) layout (Layouts), etc.)

1. Use XML to create LinearLayout

LinearLayout is a subclass of ViewGroup that is primarily used to place a horizontal or vertical sub-view part (the direction is determined by the android:orientation).

All the view will use Android:layout_width and android:layou_height.

To add a text box:

1 <  android:id= "@+id/edit_message"2        android:layout_width= " Wrap_content "3        android:layout_height=" Wrap_content "4         Android:hint = "@string/edit_message" />

The first line of the property Android:id is the identifier of the view, which refers to the object (such as the operation of reading and modifying the object), after the @ is the type of the resource, and the + sign is telling the SDK that the resource needs to be created (if it has been created, then you do not need this plus)

Two or three rows of android:layout_width and android:layout_height are used to adjust the size of the text box, it is not recommended to use a specific size, use the Wrap_content property to ensure that the view occupies only the size of the content, if you use match _parent will make the part fill the entire screen

Android:hint is a string that uses the default display, and the value of the string refers to the resource "@string/edit_message" ( How do I define a string resource?). ) should be present so do not use the + sign to add string resources by modifying the content in the Strings.xml

1 <Resources>2     <stringname= "App_name">Firstapp</string>3     <stringname= "Edit_message">Enter a message</string>4     <stringname= "Button_send">Send</string>5     <stringname= "Action_settings">Settings</string>6 </Resources>

Add button

1 <  2     android:layout_width= "Wrap_content"3    android:layout _height= "Wrap_content"4    android:text= "@string/button_send"  />

The button_send in row four is implemented by adding content from the Strings.xml <string name= "Action_settings" >Settings</string>

Android Program Development 01

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.