Android Five layout Way-linearlayout, Relativelayout, tablelayout ....
Android uses XML declaration interface layout
separating the presentation layer and the control layer of the program
No need to change the program's source code when modifying the user interface
Visual Tools Design User interface
Five ways to layout Android
LinearLayout Linear layout
Absolutelayout Coordinate layout
Relativelayout Relative layout
Framelayout Frame Layout
Tablelayout Table Layout
GridLayout
1.LinearLayout Linear layout
2.FrameLayout Frame Layout
The simplest form of layout
Components are placed in the upper-left corner of the screen, components are stacked in order, and the controls on the previous layer override the next layer of controls
3.TableLayout Table Layout
Tablelayout manages controls in the form of rows and columns, each of which behaves as a TableRow object, or a view control.
When you are a TableRow object, you can add child controls under TableRow, and each child control occupies one column by default. How many columns there are for the child control
When it is a view, the view is exclusive of one row
4.RelativeLayout Relative layout
A very flexible way of layout
Determines the layout position of all elements in the interface by specifying the relative position of the interface element with other elements
Features: To ensure the correct display of the interface layout on all screen types of mobile phones
Layout example
<?xml version= "1.0" encoding= "Utf-8"? ><relativelayout xmlns:android= "http://schemas.android.com/apk/res/ Android "xmlns:tools=" Http://schemas.android.com/tools "android:layout_width=" Match_parent "android:layout_height = "Match_parent" tools:context= "com.example.jreduch7292.BuJuActivity" ><linearlayout android:layout_width= " Match_parent "android:layout_height=" wrap_content "android:orientation=" vertical "> <textview and Roid:layout_width= "Match_parent" android:layout_height= "Wrap_content" android:text= "Popular reviews" Android:tex Tcolor= "#f40505" android:layout_marginleft= "80DP" android:textsize= "30DP"/> <linearlayout Android:layout_width= "Match_parent" android:layout_height= "wrap_content" android:orientation= "Horizont Al "> <imageview android:layout_width=" 80dp "android:layout_height=" 80DP " android:src= "@mipmap/zyf" /> <linearlayout android:layout_width= "match_parent" android:layout_height= "Wrap_co Ntent "android:orientation=" vertical "> <textview android:layout_wid Th= "Match_parent" android:layout_height= "wrap_content" android:text= "Highsmile" Android:textcolor= "#1048ef" android:textsize= "30DP"/> <textview Android:layout_width= "Match_parent" android:layout_height= "Wrap_content" android:t Ext= "The Danish security has been very good, this kind of thing can shake them all over the country" android:textcolor= "#000000" android:textsize= "30DP" /> </LinearLayout> </LinearLayout> <linearlayout android:layout_width= "match_p Arent "android:layout_height=" 90DP "android:orientation=" horizontal "android:layout_marginleft=" 80DP " Android:background= "#8c8282" > <imageview android:layout_width= "80dp" android:layout_height= "80d P "android:src=" @mipmap/zyfzyf "/> <textview android:layout_width=" Match_par Ent "android:layout_height=" Wrap_content "android:text=" Denmark bursts 2 shooting 1 deaths 6 wounds are unclear whether the relevant "android:t Extcolor= "#000000" android:textsize= "25DP"/> </LinearLayout> <linearlayout Android:layout_width= "Match_parent" android:layout_height= "wrap_content" android:orientation= "Horizontal" android:layout_marginleft= "80DP" > <textview android:layout_width= "wrap_content" android:layout_height= "Wrap_content" android:text= "5 hours Ago" android:textcolor= "#000000" Android:textsize= "20DP"/> <imageview android:layout_width= "Wrap_content" Android:layout_height= "Wrap_content "android:src=" @mipmap/like "android:layout_marginleft=" 50DP "/> &L T TextView android:layout_width= "wrap_content" android:layout_height= "Wrap_content" Android : text= "android:textcolor=" #000000 "android:textsize=" 20DP "/> <imagevie W android:layout_width= "Wrap_content" android:layout_height= "wrap_content" android:src= "@ Mipmap/message "android:layout_marginleft=" 30DP "/> <textview android:layout _width= "Match_parent" android:layout_height= "Wrap_content" android:text= "1" android:textc Olor= "#000000" android:textsize= "20DP"/> </LinearLayout> <textview Android : layout_width= "match_parent" android:layout_height= "wrap_content" android:text= "View 1 reviews" ANDROID:TEXTC Olor= "#1295f2"Android:textsize= "25DP" android:layout_marginleft= "80DP"/></linearlayout></relativelayout>
Advanced control picture screen left and right
<pre name= "code" class= "java" >package com.example.jreduch7292;import Android.os.bundle;import Android.support.v4.view.pageradapter;import Android.support.v4.view.viewpager;import Android.support.v7.app.appcompatactivity;import Android.view.view;import Android.view.viewgroup;import Java.util.arraylist;import Java.util.list;import Uk.co.senab.photoview.photoview;public class ViewPagerActivity Extends Appcompatactivity {private Viewpager VP; Private list<photoview> MyData; @Override protected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (R.layout.activity_view_pager); vp= (Viewpager) Findviewbyid (R.ID.VP); Mydata=new arraylist<> (); PhotoView img=new PhotoView (this); Img.setimageresource (R.MIPMAP.ZYFZYF); Mydata.add (IMG); Img=new PhotoView (this); Img.setimageresource (R.MIPMAP.ZYF); Mydata.add (IMG); Img=new PhotoView (this); Img.setimAgeresource (R.MIPMAP.ZZ); Mydata.add (IMG); Img=new PhotoView (this); Img.setimageresource (R.MIPMAP.ZZZ); Mydata.add (IMG); Vp.setadapter (New Myviewpageradapter (MyData)); } public class Myviewpageradapter extends Pageradapter{private list<photoview> myData; Public Myviewpageradapter (list<photoview> myData) {this.mydata=mydata; } @Override public int getcount () {return mydata.size (); } @Override Public Boolean isviewfromobject (view view, Object object) {return view==object; } @Override Public Object instantiateitem (viewgroup container, int position) {CONTAINER.ADDV Iew (Mydata.get (position)); return Mydata.get (position); } @Override public void Destroyitem (ViewGroup container, int position, object object) {container . Removeview (Mydata.get (position)); } }}
The peak of the cupola 20160729
Android Five layout methods--linearlayout, Relativelayout, tablelayout .... Four