Original: Android 0 Basics 30th: Two minutes master Framelayout frame layout
Before learning the linear layout, relative layout, and table layout, this issue is to learn the fourth layout of--framelayout frame layout.
I. Understanding Framelayout
Frame layouts are the simplest of the Android layouts, using framelayout tags.
The frame layout creates an empty area (called a frame with each control occupying one frame) for each control that is added to it. When you design an interface with frame layout, you can only display a control in the upper-left corner of the screen, and if you add multiple controls, the controls will appear in the upper-left corner of the screen in order.
The following table shows the XML attributes commonly used in framelayout and the related method descriptions.
Framelayout contains child elements that are also controlled by framelayout.layoutparams, so it contains child elements that can also specify android:layout_gravity properties. This property controls how the child element is aligned in the framelayout.
Ii. examples
Next, learn the usage of framelayout 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"?><Framelayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"> <TextViewAndroid:layout_width= "300DP"Android:layout_height= "300DP"android:layout_gravity= "Center"Android:background= "#FF33ffff" /> <TextViewAndroid:layout_width= "240DP"Android:layout_height= "240DP"android:layout_gravity= "Center"Android:background= "#FF33ccff" /> <TextViewAndroid:layout_width= "180DP"Android:layout_height= "180DP"android:layout_gravity= "Center"Android:background= "#FF3399ff" /> <TextViewAndroid:layout_width= "120DP"Android:layout_height= "120DP"android:layout_gravity= "Center"Android:background= "#FF3366ff" /> <TextViewAndroid:layout_width= "60DP"Android:layout_height= "60DP"android:layout_gravity= "Center"Android:background= "#FF3300ff" /></Framelayout>
The above interface layout definition uses the Framelayout layout and adds 5 TextView to the layout container, which reduces the height and width of the 5 TextView-so that the first TextView added will not be completely obscured; Background color gradient for 5 textview.
To run the program, you can see the interface effect shown:
Frame layouts are displayed on a frame-by-frame interface, and can often be used in game development.
Here, Framelayout's example ends, and more usage about framelayout can be practiced in more hands.
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 reproduced please note source, 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