Android development BASICS (1)

Source: Internet
Author: User

I. How to build an android development environment?

Download JDK and configure the environment variables.ArticleAnd download the Java development tool. We recommend that you use eclipse or myeclipse. After the installation is complete, click "help" and select "install new software". A new dialog box is displayed, and click "add" on the right ", the following figure is displayed, and the following content is entered:

Name can be filled in casually, the following address is: http://dl-ssl.google.com/android/eclipse/ click OK,

 

Select all the tools, and then step by step. If you have any questions, please leave a message.

2. How to add software to the android simulator?

On the Windows platform, first find the Android-SDK-Windows Directory, that is, the android Development Directory. Then find adb.exe,

Then, use the command line in Windows to verify the. APK file.

To the same directory as adb.exe, and enter the following content in cmd:

First, enter "cd" to switch to your installed ADB for execution.ProgramIf the installation directory is E: \ Android, enter "cd" E: \ Android \ platform-Tools"

Enter ADB install **. APK (note that ** here refers to your application name)

3. What are the attributes and representation of controls in Android?

The most common layout in Android is the XML method, and the HTML layout. I personally think that the layout is exquisite in HTML5 layout, but the classic layout is XML, place the XML layout file under the res \ Layout folder in the source file:

The most common XML layout is linearlayout and relativelayout.

Common attributes:
JavaCodeAssociate the control with btn1
Android: Id = "@ + ID/btn1"

Widget width
Android: layout_width = "80px" // "80dip" or "80dp"
Android: layout_width = "wrap_content"
Android: layout_width = "match_parent"

Control height
Android: layout_height = "80px" // "80dip" or "80dp"
Android: layout_height = "wrap_content"
Android: layout_height = "match_parent"

Control Layout
Android: Orientation = "horizontal"
Android: Orientation = "vertical"

Widget spacing
Android: layout_marginleft = "5dip" // left
Android: layout_marginright = "5dip" // distance to the right
Android: layout_margintop = "5dip" // distance from above
Android: layout_marginright = "5dip" // distance from the following

Widget display position
Android: gravity = "center" // left, right, top, bottom
Android: gravity = "center_horizontal"

Android: layout_gravity is the gravity direction of the element to the parent element.
Android: layout_gravity attribute sets the display position of the control relative to the parent control.
Android: gravity is the gravity direction of all child elements of the current element.

Android: layout_gravity = "center_vertical"
Android: layout_gravity = "left"
Android: layout_gravity = "Left | bottom"

Text font in textview
Android: text = "@ string/text1" // define the value of text1 in string. xml
Android: textsize = "20sp"
Android: textcolor = "# ff123456"
Android: textstyle = "bold" // normal, italic, and bold_italic)

Define whether the control is visible
Android: visibility = "visible" // visible
Android: visibility = "invisible" // invisible, but the position occupied in the layout is still
Android: visibility = "gone" // invisible, completely removed from the Layout

Define background image
Android: Background = "@ drawable/img_bg" // img_bg indicates an image under drawable.

Seekbar control background image and maximum value
Android: progressdrawable = "@ drawable/seekbar_img"
Android: thumb = "@ drawable/thumb"
Android: max = "60"

 

Valid only in relativelayout:
Relative Position of the parent Layout
Android: layout_alignparentleft = "true" // on the left of the layout
Android: layout_alignparentright = "true" // on the right of the Layout
Android: layout_alignparenttop = "true" // above the Layout
Android: layout_alignparentbottom = "true" // under the Layout

Relative Position of a widget
Android: layout_torightof = "@ ID/button1" // on the right side of the control button1, not just close
Android: layout_toleftof = "@ ID/button1" // on the left side of the control button2, not just close
Android: layout_below = "@ ID/button1" // under the control button1, not just at the bottom
Android: layout_above = "@ ID/button1" // under the control button1, not just the front and bottom

Definition and a widget
Android: layout_aligntop = "@ ID/button1" // aligntop = "@ ID/button1"
Android: layout_alignbottom = "@ ID/button1" // align with the lower part of the control button1
Android: layout_alignleft = "@ ID/button1" // align left with the control button1
Android: layout_alignright = "@ ID/button1" // right-aligned with the control button2

Android: layout_centerhorizontal = "true" // horizontally centered
Android: layout_centervertical = "true"
Android: layout_centerinparent = "true"

Valid only in linearlayout
Sets the percentage of controls in a row or column.
Android: layout_weight = "1"

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.