Crazy Android Android self-study notes

Source: Internet
Author: User

Developer-required self-learning tools:

Google search: Www.yundou.info

Android Original Development document (English) Doc http://www.phoned.cn/docs/reference/android/view/View.html

Android Original Development document (English) Doc Http://www.phoned.cn/docs.zip due to Google blocked page related to Google API can not be called Open will be very card recommended off-screen or FQ after use.

2015-12-24

View components:

The vast majority of Android base controls are present in the package Android.widget,android.view and its child packages.

All of the UI infrastructure components inherit the view class, and view is a blank panel.

ViewGroup has the function of view, which is usually used as a container for view, and it is an abstract class, in order to reduce the method of replication usually uses the ViewGroup subclass as the container.

ViewGroup controls the layout of components placed inside its container through its own internal class Layoutparams,marginlayoutparams XML method.

Developers can customize a personalized UI component by inheriting the view class and implementing its methods. The basic way of overriding the view constructor is usually implemented.

A class that inherits from view overrides its method, and the object generated by the class will follow the overridden method to generate the corresponding shape or effect.

If you cannot find the control you have created when you use R to refer to the control or file, see if the introduced R file is the current package's R file.

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

December 25, 2015

To re-explore the layout:

LinearLayout flow layout, components can be arranged in a horizontal or vertical order, the components will push each other, due to the limited size of the screen, sometimes the control will be pushed outside the screen and cannot see the control.

GridView Grid layout, specifying rows and columns after the view control is added.

Tablelayout table layouts, add child controls in a row control without specifying a row and column beforehand, and adding the number of rows.

Framelayout the frame layout, each control will be superimposed in the loading order.

Relativelayout the relationship layout, where the positions of the controls are placed as references to the positions of the other controls.

Absolutelayout Absolute Layout, the position of the control is determined by the developer, and the control is placed strictly according to the x, Y coordinates.

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

December 26, 2015

In-depth activity

The activity stack is composed of a large number of activities, and the current event is at the top of the stack.

The inheritance graph shows that activity indirectly inherits the base class such as Context,contextwrapper,contextthemewrapper.

What is a callback: a call behavior that occurs at a particular moment, such as a callback function. A call B to handle the related transaction, b in processing the transaction requires a to provide a function to handle the transaction c,c is called a callback function, why a does not go directly to the processing and let B to handle, in the process of processing B may not just deal with a transaction, but also handle other types of transactions, In the process of processing various types of transactions, some of the underlying implementation logic is consistent, so encapsulated B, reduce the redundancy of the underlying implementation code, for a general-purpose program architecture, the program to complete the application of the general function, process, but at a specific point, A developer-defined code related to the software business needs to be executed, and the code is "individual" and the generic program architecture cannot complete the code.

After the execution of the internal logic of the program, it is necessary to call that segment by a developer-defined function or code to implement a specific function, usually in two ways to complete the writing of this function code: one is to use the new interface, the replication of its callback method to embed its own code. The other is to replicate its abstract or non-abstract class methods by inheriting the abstract or non-abstract class method of the base class to complete the code embedding.

December 27, 2015

Understanding Intent Related

Android uses the same intent model to encapsulate the start-up between modules, providing a unified programming model for each module component.

ComponentName (A1,A2); A

The parameter A1 represents the package corresponding to A1, A1 can be a string, Context.

The parameter A2 represents the component, and the A2 can be string, class.

The intent property action and category are a way to set a static string, the action method represents the behavior that intent needs to complete (open, view, and so on), and the category method provides additional information for the action.

Intent sets the method of combination of category and action only defines the behavior of intent and the behavior of the additional information, and does not specify the object to perform this behavior, through intent-filter to control the execution of the object, When you configure the activity's intent-filter in manifest, the activity is likely to be started.

The intent-filter is used to specify the performer of the action, thus cutting off the bond between the behavior and the performer, and the relationship between the behavior and the performer is pluggable, so the design reduces the coupling degree of the program.

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

December 29, 2015 (Supplementary chapter)

Android Resource Operation

Resources stored in the Res directory in the Android directory will automatically generate an index in the R file, which can be referenced directly in the code. Assets is also a directory of resources, storing native resources that cannot be accessed directly by Android and need to be read using Assetsmanager binary streams.

The identity symbol that is referenced in the XML code by using the @ symbol in addition to the system-defined resource name you can use the name tag to customize the resource name in the XML resource file.

Size, color, string resource, defined in the Value folder under Res, when referencing a resource with the @ symbol in the format for example: @string/title refers to the value of item under the string file named title under Value.

An array of XML resources in the form of three arrays defined in XML root tags <resource>:<array> normal <string-array> string <integer-array> shaped arrays.

The root tag <layer-list> is the XML declaration format for layerdrawable, which contains the Drawable object (DRAWABLE=XXX) and can contain multiple drawable. The drawing order is drawn sequentially according to the index size.

Five Resources special effects controls statelistdrawable, Layerdrawable, Shapedrawabe, Clipdrawable, animationdrawable.

Statelistdrawable root tags <seloctor> settings control events occur when the event changes.

Layerdrawable root tags <Layer> draw graphics based on drawable objects.

Shapedrawable root Tags <Shape> set controls visual effects such as fillets, fills, edges, gradients.

Clipdrawable root tag <Clip> capture a clip of a particular location in the picture.

Animationdrawable root Tags <set> set an animation resource.

Raw XML: Save some initialization parameters or a small amount of configuration information, a lot of information can be recorded using SQLite.

Requirement: A file that is syntactically compliant with the XML specification.

Getxml (int id) gets Xmlpullparser object for XML-related operations by parsing the XML class Xmlresourceparser method.

Use the method Openrawresource method of the InputStream class to get the XML input stream.

Menu resource./res/menu root tab <menu> Set the contents of the menu by setting its embedded element item.

By overriding the context menu method Oncreatecontextmenu can load the menu resource file as a context menu, or it can be used elsewhere, in a similar manner.

Theme theme resources are defined in Android.

Control style Control: Root tab <resource> through child tags <style> add properties. Child tags <style> The name of the style can be specified by name, and parent specifies an inherited item.

Activity Theme Control: The activity Theme XML format is similar to style control, item items are used in the form of system function android:windowxxx writing.

The activity's Settheme method allows you to set a theme for a single activity, and the unified settings theme can be set in manifest.

Attribute a property resource, the root tag is <resource>,attr as a child element, and Declare-styleable is a collection of attributes.

The code obtains the property through the AttributeSet method.

Attribute properties of objects are managed and normalized.

When you use a property, you import the package that contains the attribute in the project XML layout. Namespaces: Xmlns:xxx.android.com/apk/res/packge

The main classes of internationalization of Android programs: Resourcebundle,locale, translation files are stored in Key-var key-value pairs, and converted to Unicode format by NATIVE2VEASCII.

The internationalization of Android programs can also be achieved by setting the String.xml key value pairs (<string name= "OK" > Good </string>) in different language named folders (VALUE-ZH-RCN) under Res. 、

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

Graphics and image processing (mostly hands-on)

The bitmap represents a bitmap, and the bitmapdrawable encapsulates the bitmap object.

Accessing an image in a path other than the Android program itself requires the use of bitmapfactory to resolve the creation of the bitmap object.

Creating bitmap objects often requires device memory, and the Bitmap object method Isrecycle () method determines whether the recycle () method is reclaimed to force recycling.

Inheriting the view component overrides the OnDraw method to achieve painting.

Canvas represents the canvas, and paint represents the brush. Use their respective methods to achieve different effects of painting.

Path represents any shape that is linked to any multi-strand line. It can pre-link n dots into a path in view, and then use the canvas's DrawPath method to draw the graph along the path.

Patheffect defines the effect of drawing.

Matrices are a matrix tool class provided by Android, combined with other APIs to control the transformation of graphical components.

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

January 1, 2016 (Supplement two chapters)

Android data stored in IO stream

The Sharedpreferences interface is in the form of key-value pairs: for storing small amounts of information, such as configuration information, software-related external memory.

Sharedpreferences provides a series of read and write operations to external files.

The Sharedpreferences internal interface Editor provides methods for writing and purging data.

The sharedpreferences itself is an interface that cannot be used to generate its objects using the new method, and forcing the new method to generate its objects is written in the form of an inner class. Use Context.getsharedpreferences (); Get object.

The context provides a set of IO file streams that read the files under the Data folder of the current application: Openfileinput openfileoutput.

Read and write SD card file: Environment Getexternalstoragestate (), determine the status of SD card.

getExternalStorageDirectory () Gets the SD card directory.

Read and write files using the FileInputStream fileoutputstream filereader FileWriter method.

PostScript: Learn to read this only reading but there is no egg, light understanding of the content is not enough, engineering materials need to grasp the side of the actual combat, and if you can not insist on the front to do more will soon forget. January 2, 2016

Crazy Android Android self-study notes

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.