Java-Android learning (Third Day)

Source: Internet
Author: User

Java-Android learning (Third Day)

Android program entry point

In the first day,⑤ Program entry point.I mentioned the program entry point, but it is general,

Here, let's talk about it again:

The AndroidManifest. xml file contains the following nodes:

                     
                                  
               
              

All Activity programs are registered in the AndroidManifest. xml file. Therefore, this file is the core configuration file of the entire Android project.

The android: icon = "@ drawable/ic_launcher" configured in the node indicates that drawable (drawable-hdpi, drawable-ldpi, and drawable-mdpi are referenced) resource Configuration icon. The name of the import icon is ic_launcher;

The android: label = "@ string/app_name" configured in the node indicates that the tag name of this application is from strings. the content in the xml file is the content corresponding to app_name; of course, you can also change the title of the Activity.

An Activity is a form of an Activity. A project application can contain multiple activities.

              
   
  

Activity contains the preceding tag, indicating that the program is the Activity where the tag is started by default:

The method is roughly as follows:

① Android: name = ". MainActivity" specifies the. java file in src;

② In the corresponding. java File

Protected void onCreate (Bundle savedInstanceState ){
Super. onCreate (savedInstanceState );
SetContentView (R. layout. activity_main );

}

SetContentView (R. layout. activity_main); specifies the layout XML in res-layout.

//////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// ///////////////////////////

Page Layout

Common page la s include:

LinearLayout: uses the orientation attribute to set whether the direction of the linear arrangement is vertical or horizontal );

RelativeLayout (relative layout), where the control positions are calculated based on relative positions, and where the latter control depends on the basic positions of the previous control, which is the most commonly used layout, it is also the most flexible layout.

For example:

 
 
 

In addition, Introduction to common properties of relative layout (reference: http://blog.csdn.net/jianghuiquan/article/details/8298687 ):

  ①. Category 1: the property value is true or false android: layout_centerHrizontal horizontal center android: layout_centerVertical vertical center android: layout_centerInparent completely center relative to parent element android: Align align to the bottom edge of parent element android: layout_alignParentLeft: Stick the left edge of the parent element. android: layout_alignParentRight: Stick the right edge of the parent element. android: layout_alignParentTop: Stick the top edge of the parent element.
②. Category 2: the property value must be the reference name of the id "@ id/id-name" android: layout_below at the bottom of an element android: layout_abve at the top of an element android: layout_toLeftOf on the left of an element android: layout_toRightOf on the right of an element android: layout_alignTop the top edge of this element is aligned with the top edge of an element android: the left edge of the layout_alignLeft element is aligned with the left edge of an element. The bottom edge of the android: layout_alignBottom element is aligned with the bottom edge of an element. android: layout_alignRight
③ Category 3: The property value is a specific pixel value, for example, 30dip, 40px android: layout_marginBottom, the distance from the bottom edge of an element android: layout_marginLeft to the left edge of an element android: the distance between layout_marginRight and the right edge of an element android: layout_marginTop

Thank you for your post!

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.