Prior to the basic study of Android development commonly used in four kinds of layout, the reason is to put absolutelayout in the back to learn, because in the actual development is rarely used, and in the high version has commented to delete is not recommended to use, then the purpose of this period of learning is to simply understand that there is such a layout, If you run into at least know what's going on.
I. Understanding Absolutelayout
Absolute layouts need to control the position of each control by specifying x, y coordinates, and the controls placed in that layout need to specify their exact coordinate values through android:layout_x and android:layout_y two properties and display them on the screen.
It is important to note that when using Absolutelayout as a layout container, the layout container no longer manages the location and size of the child components, requiring the developer to control it. With absolute layout, each subcomponent can specify the following two XML attributes.
Ii. examples
Next, learn the usage of absolutelayout using a simple example program.
Also using the Widgetsample project, continue to use the Activity_main.xml file in the app/main/res/layout/directory, where the following code snippet is populated:
<?XML version= "1.0" encoding= "Utf-8"?><Absolutelayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"> <ButtonAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"android:layout_x= "0DP"android:layout_y= "0DP"Android:text= "Button 1" /> <ButtonAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"android:layout_x= "40DP"android:layout_y= "40DP"Android:text= "button 2" /> <ButtonAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"android:layout_x= "80DP"android:layout_y= "80DP"Android:text= "button 3" /> <ButtonAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"android:layout_x= "120DP"android:layout_y= "120DP"Android:text= "button 4" /></Absolutelayout>
To run the program, you can see the interface effect shown:
It is important to note that in theory absolute layouts can be completed for any layout design, but the use of this layout is not advocated in actual engineering applications. Because using this layout requires not only a precise calculation of the size of each component, but also the effect of the application running on a different screen of the phone, it is generally not recommended to use absolute layout. We can generally use linearlayout weight weight + relativelayout to build our interface.
Come here today, if you have any questions welcome message to discuss together, also welcome to join the Android 0 Basic introductory Technical discussion group, grow together!
This article copyright for the public Share talent show (Shareexpert)--Xin 鱻 all, if necessary reprint please contact the author authorized, hereby declare!
Past period Summary share:
Android 0 Basics Introduction 1th: Android's past life
Android 0 Basics Section 2nd: Android system Architecture and application components those things
Android 0 Basics Section 3rd: Bring you up to talk about Android development environment
Android 0 Basics 4th: Installing and configuring the JDK correctly Ko fu the first trick
Android 0 Basics 5th: Use ADT bundles to easily meet the goddess
Android 0 Basics 6th: Configuration Optimization SDK Manager, official dating goddess
Android 0 Basics 7th: Take care of Android simulator and start the Sweet journey
Android 0 Basics 8th: HelloWorld, the starting point for my first trip
Android 0 Basics 9th: Android app, no code can be developed
Android 0 Basics Section 10th: Development IDE Big upgrade, finally ushered in Android Studio
Android 0 Basics Introductory Section 11th: Simple steps to take you to fly, run Android Studio project
Android 0 Basics 12th: Get familiar with the Android studio interface and start selling
Android 0 Basics 13th: Android Studio Configuration optimization to create a development tool
Android 0 Basics 14th: Using high-speed genymotion, stepping into the rocket era
Android 0 Basics Section 15th: Mastering the Android Studio project structure, sailing
Android 0 Basics Section 16th: Android User Interface Development overview
Android 0 Basics Section 17th: TextView Properties and Methods Daquan
Android 0 Basics Section 18th: EditText properties and how to use them
Android 0 Basics section 19th: Button usage explained
Android 0 Basics Section 20th: checkbox and RadioButton Usage Daquan
Android 0 Basics Section 21st: ToggleButton and switch usage Daquan
Android 0 Basics Section 22nd: ImageView's properties and methods Daquan
Android 0 Basics Section 23rd: ImageButton and Zoombutton use Daquan
Android 0 Basics Section 24th: Customize view simple to use to create your own controls
Android 0 Basics Section 25th: Simple and most commonly used linearlayout linear layouts
Android 0 Basics Section 26th: Two alignments, layout_gravity and gravity differ greatly
Android 0 Basics section 27th: Using padding and margin correctly
Android 0 Basics Section 28th: Easy to master relativelayout relative layout
Android 0 Basics 29th: Use tablelayout table layouts
Android 0 Basics 30th: Two minutes master Framelayout frame layout
Android 0 Basics Section 31st: Almost no, but to understand the absolutelayout absolute layout