Android View Frame
Android UI system is the core of Android application System framework, the most basic content!
1. Android View system, hierarchical relationship
Android app design is similar to Web application design, and also sub-front and back-end design. The core elements and four components of Android belong to the backend design section, and the UI design is the front-end design. The front-end design determines the user experience is good or bad, the back-end design determines the function of complete and application of security, stability.
For Android UI design, the two most important classes used are: View and ViewGroup. They determine the shape of the appearance interface that is presented to the user. The following describes the hierarchical relationship of the Android view system:
Figure 1. Interface (UI)
The view class is the base class for all view controls, including ViewGroup. Various UI controls inherit the view class, implementing specific functions by implementing different interfaces. About the inheritance relationship, say more, convenient for everyone to understand the control more clearly, see:
Figure 2. Control inheritance Relationship
Figure 3. Common UI Controls
2. Android View Framework MVC model
The Android UI Framework is also organized using MVC, which provides the controller to handle user input, act on the model, and feed the results back to the view, rebuilding the view, rendering to the screen.
Figure 4. The MVC model of the Android UI
3. Android View Execution Process analysis
In the development of Android, the view layout is written in an XML file, by adding the appropriate controls to the XML file and setting its properties to the layout. A simple layout file is as follows:
Demo.xml File Contents
<?xml version= "1.0" encoding= "Utf-8"?> //Declaration XML file encoding and version <linearlayout //using linear layouts, internal controls, 17 linear arrangement// Reference namespace Xmlns:android= "Http://schemas.android.com/apk/res/android" android:layout_width= "Fill_parent" Android: layout_height= "Fill_parent" android:padding= "5DP" android:orientation= "vertical" > //Internal Control arrangement direction: vertical Arrangement < EditText //Add a text input box control android:id= "@+id/show" //Set the control id//to the end for the various property settings for the control so that it shows a specific style on the interface Android:layout_ Width= "Match_parent" android:layout_height= "wrap_content" android:layout_margintop= "10DP" android:layout_weight= " 2 "android:lines=" 3 "android:editable=" false "android:gravity=" Top|right "android:cursorvisible=" true "Android:text = "" android:textsize= "24sp"/> //End the control </LinearLayout> //Layout End Indicator
Once a layout file (Demo.xml) is created, create a new Test.java file to use the layout file, as follows:
Test.java File Contents
Packagecom. Acerwang.test;Importandroid.app.Activity;ImportAndroid.os.Bundle;ImportAndroid.view.View;//the new test must inherit activity in order to create an active Public classTestextendsactivity{//overloading the OnCreate method, generating a new activity, the rendering of the view in the activity, activity executionThe action of the activity, as described in the previous article . @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);//output the previously written layout file to the screenSetcontentview (R.layout.demo); }}
4. Summary
The above is a simple introduction to the structure, principle and implementation process of Android view frame, hoping to help the novice. Introduction of the principle is more, more boring, but very important, I hope to insist on more look at the future development of the benefits. Of course, there are many deep-seated content is not involved, in the future study and share, the writing process of the improper place also please point out that we learn from each other, common progress!
Android View Frame