yesterday saw the next several common layouts, similar to the previous learning of HTML, about Css+div no contact too much, but these kinds of layout are relatively simple, as long as the logic is not too big problem can be the whole.
Relative layout is our usual default layout, is also the most commonly used, the front of the "Phone Dialer" and "SMS Transmitter" is used it. This layout emphasizes the relative position of the control, such as the use of the ID of the person who is in the bottom or top, to customize the entire UI through the spatial position relationship. Suppose there are two controls, one ID is TV, the other ID is XC, to make XC under the TV, you can use such a statement in XC----android:layout_below= "@id/tv", concise and clear, English over three can be read. Of course, in a relative layout, you can adjust the control's spatial position by the variable value, relative to the parent form, or set a specific parameter value to achieve the specific requirements.
Linear layout compared to the former is very simple, it is horizontal vertical, there is no alignment is not aligned, all the controls are on a line, it is usually mixed with the relative layout, such as some of our phone system settings, a list of items and a single box or check box, which can be achieved by the combination of both.
Table layout, as the name implies, through the column to design the UI, this is usually used for identity information verification layout, such as name, age, gender, ID number, etc., it and linear layout almost, can make the same effect.
Absolute layout, that is, through layout_x and layout_y to determine the position of a control relative to the form, such as the QQ game Happy bucket Landlord is through the absolute layout to achieve, poker location using specific parameters to locate, but now this layout has been discarded, Because the Android device has a large screen, if you rely on this absolute position information to determine the position of a control in the form is prone to deviation, so now is the dynamic calculation of the width of the screen, and then use a percentage to define the specific location of the control, this is also the times.
The last one is what you think is the most interesting layout-the frame layout, which is like an onion, consisting of a layer of interface. We usually watch the video click on the pause generally will appear a button, is a small icon, then click on it will play normally, OK, first on a section of code:
<textview android:layout_width= "match_parent" android:layout_height= "Match_parent" Android:text = "Play video" android:gravity= "center" android:visibility= "visible"/> <linearlayout an Droid:layout_width= "Fill_parent" android:layout_height= "match_parent" android:orientation= "Horizontal" > <button android:onclick= "Play" android:layout_width= "Wrap_content" Androi d:layout_height= "Wrap_content" android:text= "Play"/> <button Android:onclick = "Pause" android:layout_width= "wrap_content" android:layout_height= "Wrap_content" android:t ext= "Pause"/> </LinearLayout> <linearlayout android:layout_width= "Match_parent" android:layout_height= "match_parent" android:gravity= "center" > <imageview Andro Id:id= "@+id/iv"Android:layout_width= "Wrap_content" android:layout_height= "wrap_content" android:src= "@drawable/ic_launche R "android:visibility=" Invisible "/></linearlayout>
This code is the simple video playback interface we made four small parts, exactly three sections, from top to bottom is playing video tips, two buttons, and a pause when the small icon displayed. Introduce several important parameters: visibility= "Visible", this is the setting icon is displayed, the back we want to use it to set the play or pause the state of the small icon; src= "@drawable/ic_launcher", set the picture source, This can be defined by itself, onclick= "Pause", set the Click event, and prepare for the subsequent status display. Another paragraph:
Private ImageView IV; @Override protected void onCreate (Bundle savedinstancestate) { super.oncreate (savedinstancestate); Setcontentview (r.layout.test_frame); iv= (ImageView) Findviewbyid (R.ID.IV); } public void Play (view view) { iv.setvisibility (view. INVISIBLE); } public void Pause (view view) { iv.setvisibility (view). VISIBLE); }
This is to specify the click Play or Pause button when the state of the small icon, first get the icon, and then set when the "play" to hide the icon, accept "Pause" when the display icon, the final effect is as follows:
The former is the state when playing, the latter is the state of the pause, OK, today first ...