1,android:orientation
Layout direction. Horizontal is to have all the child elements in the horizontal direction from left to right, vertical is to have all the child elements in the vertical direction from top to bottom in the arrangement.
The difference between 2,android:gravity and android:layout_gravity android:gravity refers to the alignment of the child elements of the final element with the corresponding method.
Android:layout_gravity refers to the alignment of the element relative to its parent element.
For example:
Here's the LinearLayout android:gravity set to right, with two child elements Button01 and BUTTON02.
Java code:
Copy Code code as follows:
<?xml version= "1.0″encoding=" utf-8″?>
<linearlayout xmlns:android= "Http://schemas.android.com/apk/res/android"
android:orientation= "Vertical"
Android:layout_width= "Fill_parent"
android:layout_height= "Fill_parent"
Android:gravity= "Right"
>
<button android:text= "button01″android:id=" @+id/button01″android:layout_width= "Wrap_content" Android:layout_ height= "Wrap_content" ></Button>
<button android:text= "button02″android:id=" @+id/button02″android:layout_width= "Wrap_content" Android:layout_ height= "Wrap_content" ></Button>
</LinearLayout>
The linearlayout in this main.xml also has two child elements Button01 and BUTTON02. Button01 's android:layout_gravity is set to "left" and Button02 's android:layout_gravity is set to "right"
Java code:
Copy Code code as follows:
<?xml version= "1.0″encoding=" utf-8″?>
<linearlayout xmlns:android= "Http://schemas.android.com/apk/res/android"
android:orientation= "Vertical"
Android:layout_width= "Fill_parent"
android:layout_height= "Fill_parent"
>
<button
Android:layout_gravity= "left"
Android:text= "Button01″
Android:id= "@+id/button01″
Android:layout_width= "Wrap_content" a
ndroid:layout_height= "Wrap_content" ></Button>
<button
Android:layout_gravity= "Right"
Android:text= "Button02″
Android:id= "@+id/button02″
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content" >
</Button>
</LinearLayout>
famelayout Layout
Framelayout is one of the simplest layout objects. It is customized to a blank standby area on your screen, and you can then populate it with a single object-for example, a picture you want to post. All the child elements will be pinned to the upper-left corner of the screen; You cannot specify a location for a child element in the framelayout. The latter child element will cover the padding directly on top of the previous child element, blocking them partially or completely (unless the latter element is transparent).
XML attribute
1, define the interface with an XML file, and then the Setcontentview method of the activity creates the real control object based on the definition in the XML file. Like an XML file is a design drawing, Setcontentview is a production machine, it produces a variety of cups and washing according to the drawings.
2,framelayout's XML attributes come from three places: inherited, nested class-defined, defined by its own class.
3, with the properties of the official documents can be consulted. Here are a few of the properties you've just encountered.
Java code:
Copy Code code as follows:
Android:id
//This XML property is an XML attribute inherited from the Android.view class. It provides a unique identifier for framelayout, which can then be found using View.findviewbyid () or Activity.findviewbyid () when the program uses it.
Android:layout_width: Layout width
Android:layout_height: layout is high
//their value is fill_parent or wrap_content.
Fill_parent: Space on the x-axis or on the y-axis that fills the parent container.
the number of elements in the wrap_content:framelayout how wide the height is,
// Both of these attributes are defined in the nested class android.widget.FrameLayout.LayoutParams of android.widget.FrameLayout.
Android:background: Background
Android:foreground: foreground