Android authoritative Programming Guide reading notes (1-2 chapters)

Source: Internet
Author: User

Chapter One first Android app experience

1.4 User Interface Design

<?xml version= "1.0" encoding= "Utf-8"?>

The line code is no longer required for Android layout files after the ADT21 development version.

1.4.1 View structure hierarchy (view hierarchy)

ViewGroup Component inherited to view: Linearlayout/framelayout/relativelayout

1.4.3 String Resource

The general default is named Strings.xml, or you can customize the naming, but these files are placed in the res/values directory and contain a resources root element and multiple string child elements

1.8Android compilation process

AAPT (Android Asset Packaging Tool) compresses the resource files and packs them into an . apk file. When the activity class OnCreate method calls the Setcontentview method, it uses Layoutinflater to instantiate each View object in the layout file by reflection (eg: <LinearLayout/> classloader.load("LinearLayout") <TextView/> classloader.load ("TextView"))

Chapter II Android and MVC design Patterns

2.1 Generating getter and setter methods

We know that in Android, the member variable convention is prefixed with m as the variable name, so that when writing getter and setter, it is more than a m in front of the method name, in order to automatically generate the method in eclipse, ignore this prefix, you can do the following settings

The Windows->preferences->java->code Style is filled with M and s for the Prefix list of the fields, variable, and the type, respectively. The resulting method ignores the prefix.

2.2 Android and MVC design Patterns

2.2.1 Model Object (M): Stores the app's data and business logic, which does not care about the user interface

2.2.2 View Object (V): An object that can be seen on the screen, that is, the kind of component defined by the layout file

2.2.3 Control Object (C): The link between the view and the model object. The control object (m) is designed to respond to kinds of events triggered by the View object (v), and also to manage the data flow of the model object (m) and the View object (v). Android typically refers to a subclass of Activity/Fragment or Service

2.6 Adding icon Resources

Store customized images for different DPI devices in different directories to avoid distortion using only one set of images

mdpi: Medium pixel density screen (approx. 160dpi)

hdpi: High pixel density screen (approx. 240dpi)

xhdpi: Ultra high Pixel password screen (approx. 320dpi)

Android authoritative Programming Guide reading notes (1-2 chapters)

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.