Layout of Android Interface design

Source: Internet
Author: User

First, linear layout

<linearlayout 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 "Android:orien tation= "vertical" android:paddingbottom= "@dimen/activity_vertical_margin" android:paddingleft= "@dimen/activity_ Horizontal_margin "android:paddingright=" @dimen/activity_horizontal_margin "android:paddingtop=" @dimen/activity_ Vertical_margin "tools:context=". Test01activity "> <!--Linear Layout--<linearlayout android:layout_width=" Match_parent "Android: layout_height= "wrap_content" android:orientation= "horizontal" > <button android:id= "@+id/bt N1 "android:layout_width=" Wrap_content "android:layout_height=" Wrap_content "Android:text = "1"/> <button android:id= "@+id/btn2" android:layout_width= "Wrap_content" a Ndroid:layout_height= "Wrap_content" android:text= "2"/> <button android:id= "@+id/btn3" android:l Ayout_width= "Wrap_content" android:layout_height= "Wrap_content" android:text= "3"/> <Bu Tton android:id= "@+id/btn4" android:layout_width= "wrap_content" android:layout_height= "WR Ap_content "android:text=" 4 "/> </LinearLayout> <linearlayout android:layout_width=" Ma            Tch_parent "android:layout_height=" wrap_content "android:orientation=" Horizontal "> <button Android:id= "@+id/btn5" android:layout_width= "wrap_content" android:layout_height= "Wrap_cont Ent "android:text=" 4 "/> <button android:id=" @+id/btn6 "android:layout_width            = "Wrap_content" android:layout_height= "Wrap_content" android:text= "5"/> <button Android:id= "@+id/btN7 "android:layout_width=" wrap_content "android:layout_height=" Wrap_content "Android:text = "6" android:layout_weight= "1"/> </LinearLayout></LinearLayout>

Results:


Second, relative layout

<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 "Android:paddi ngbottom= "@dimen/activity_vertical_margin" android:paddingleft= "@dimen/activity_horizontal_margin" Android: paddingright= "@dimen/activity_horizontal_margin" android:paddingtop= "@dimen/activity_vertical_margin" tools: Context= ". Mainactivity > <!--relative layout-<button android:id= "@+id/bbtn1" Android:layout_widt H= "Wrap_content" android:layout_height= "wrap_content" android:text= "Central" android:layout_c Enterhorizontal= "true" android:layout_centervertical= "true"/> <button android:i D= "@+id/bbtn2" android:layout_width= "wrap_content" android:layout_height= "Wrap_content" a ndroid:text= "upper left Corner" android:layout_above= "@Id/bbtn1 "android:layout_toleftof=" @id/bbtn1 "/> <button android:id=" @+id/bbtn 3 "android:layout_width=" Wrap_content "android:layout_height=" Wrap_content "android:text= "Bottom left" android:layout_below= "@id/bbtn1" android:layout_toleftof= "@id/bbtn1"/> < Button android:id= "@+id/bbtn4" android:layout_width= "Wrap_content" android:layout_height= "Wrap_content" android:text= "bottom Right" android:layout_below= "@id/bbtn1" android:layout_toright of= "@id/bbtn1"/> <button android:id= "@+id/bbtn5" android:layout_width= "Wrap_co Ntent "android:layout_height=" wrap_content "android:layout_torightof=" @id/bbtn1 "Android:layout_abov E= "@id/bbtn1" android:text= "top right"/> </RelativeLayout>

Results:

Three, Grid layout

<gridlayout xmlns:android= "http://schemas.android.com/apk/res/android" android:layout_width= "Wrap_content" an droid:layout_height= "wrap_content" android:orientation= "Horizontal" android:rowcount= "5" Android:columnCoun t= "4" > <!--network Layout--<button android:id= "@+id/bbtn1" android:layout_width= "Wra P_content "android:layout_height=" wrap_content "android:text=" Central "android:layout_centerh Orizontal= "true" android:layout_centervertical= "true"/> <button android:id= "@+id/ Bbtn1 "android:layout_width=" wrap_content "android:layout_height=" Wrap_content "android:t ext= "Central" android:layout_centerhorizontal= "true" android:layout_centervertical= "true"/&G  T <button android:id= "@+id/bbtn1" android:layout_width= "Wrap_content" Android:layout_hei  ght= "Wrap_content"          android:text= "Central" android:layout_centerhorizontal= "true" android:layout_centervertical= "t            Rue "/> <button android:id=" @+id/bbtn1 "android:layout_width=" Wrap_content "            android:layout_height= "wrap_content" android:text= "Central" android:layout_centerhorizontal= "true"            Android:layout_centervertical= "true"/> <button android:id= "@+id/bbtn1"             Android:layout_width= "Wrap_content" android:layout_height= "wrap_content" android:text= "central"            Android:layout_centerhorizontal= "true" android:layout_centervertical= "true"/> <button Android:id= "@+id/bbtn1" android:layout_width= "wrap_content" android:layout_height= "Wrap_con Tent "android:text=" Central "android:layout_centerhorizontal=" true "Android:layout_centervert Ical= "true"/> <button android:id= "@+id/bbtn1" android:layout_width= "Wrap_content" Android:layo ut_height= "wrap_content" android:text= "Central" android:layout_centerhorizontal= "true" Androi D:layout_centervertical= "true"/> <button android:id= "@+id/bbtn1" Android:layout_w Idth= "Wrap_content" android:layout_height= "wrap_content" android:text= "Central" android:layou T_centerhorizontal= "true" android:layout_centervertical= "true"/> <button android:            Id= "@+id/bbtn1" android:layout_width= "wrap_content" android:layout_height= "Wrap_content"            android:text= "Central" android:layout_centerhorizontal= "true" android:layout_centervertical= "true" /> <button android:id= "@+id/bbtn1" android:layout_width= "Wrap_content" Andro Id:layout_height= "Wrap_cOntent "android:text=" Central "android:layout_centerhorizontal=" true "Android:layout_centerve Rtical= "true"/> <button android:id= "@+id/bbtn1" android:layout_width= "Wrap_conten T "android:layout_height=" wrap_content "android:text=" Central "Android:layout_centerhorizonta            L= "true" android:layout_centervertical= "true"/> <button android:id= "@+id/bbtn1"              Android:layout_width= "Wrap_content" android:layout_height= "wrap_content" android:text= "central" Android:layout_centerhorizontal= "true" android:layout_centervertical= "true"/> < Button android:id= "@+id/bbtn1" android:layout_width= "Wrap_content" android:layout_height= "Wrap_content" android:text= "Central" android:layout_centerhorizontal= "true" Android:layout_c    Entervertical= "true"        /> <button android:id= "@+id/bbtn1" android:layout_width= "Wrap_content" and            roid:layout_height= "wrap_content" android:text= "Central" android:layout_centerhorizontal= "true" Android:layout_centervertical= "true"/> <button android:id= "@+id/bbtn1" Android : layout_width= "wrap_content" android:layout_height= "wrap_content" android:text= "Central"/&gt  ; <button android:id= "@+id/bbtn1" android:layout_width= "Wrap_content" Android:layout_hei ght= "Wrap_content" android:layout_rowspan= "2" android:layout_gravity= "Fill" android:text=            "="/> <button android:id= "@+id/bbtn1" android:layout_width= "Wrap_content" android:layout_height= "Wrap_content" android:text= "+" android:layout_columnspan= "2 "Android:layout_gravity= "Fill"/> <button android:id= "@+id/bbtn1" android:layout_width= "Wra P_content "android:layout_height=" wrap_content "android:text=" Central "/> </gridlayout   >


Results:

Iv. Layout of the table

<?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "http://schemas.android.com/apk/res/ Android "    android:layout_width=" fill_parent "    android:layout_height=" fill_parent "    android:o rientation= "vertical"    android:padding= "3dip" >    <!--1th Tablelayout, which describes the column properties in a table. The No. 0 column can be stretched, the 1th column can be shrunk, and the 2nd column is hidden--   <tablelayout        android:layout_width= "fill_parent"       android:layout_ height= "Wrap_content"       android:stretchcolumns= "1"       >       <tablerow >           <textview   android:text= "Nihao"/>                  </TableRow>        <tablerow >           <textview   android:text= " Hello ihdsakj "/>            <button   android:text=" Hello ihdsakj "/>       </TableRow>       <tablerow >           <button   android:text= "Hello ihdsakj"/>                  </TableRow>             </TableLayout>   </LinearLayout>

Results

:

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.