zoukankan      html  css  js  c++  java
  • Android UI — LinearLayout、TableLayout、RealitiveLayout

    LinearLayout:

     1 <?xml version="1.0" encoding="utf-8"?>
     2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     3     android:orientation="vertical"
     4     android:layout_width="fill_parent"
     5     android:layout_height="fill_parent"
     6     >
     7     <LinearLayout 
     8         android:orientation="horizontal"
     9          android:layout_width="fill_parent"
    10            android:layout_height="fill_parent"
    11         android:layout_weight="1">
    12         <TextView
    13           android:text="red"
    14           android:gravity="center_horizontal"
    15           android:background="#aa0000"
    16           android:layout_width="wrap_content"
    17           android:layout_height="fill_parent"
    18           android:layout_weight="1"/>
    19       <TextView
    20           android:text="green"
    21           android:gravity="center_horizontal"
    22           android:background="#00aa00"
    23           android:layout_width="wrap_content"
    24           android:layout_height="fill_parent"
    25           android:layout_weight="1"/>
    26       <TextView
    27           android:text="blue"
    28           android:gravity="center_horizontal"
    29           android:background="#0000aa"
    30           android:layout_width="wrap_content"
    31           android:layout_height="fill_parent"
    32           android:layout_weight="1"/>
    33       <TextView
    34           android:text="yellow"
    35           android:gravity="center_horizontal"
    36           android:background="#aaaa00"
    37           android:layout_width="wrap_content"
    38           android:layout_height="fill_parent"
    39           android:layout_weight="1"/>
    40        </LinearLayout>
    41        
    42        
    43     <LinearLayout 
    44         android:orientation="vertical"
    45          android:layout_width="fill_parent"
    46            android:layout_height="fill_parent"
    47         android:layout_weight="1">
    48     <TextView
    49         android:text="row one"
    50         android:textSize="15pt"
    51         android:layout_width="fill_parent"
    52         android:layout_height="wrap_content"
    53         android:layout_weight="1"/>
    54     <TextView
    55         android:text="row two"
    56         android:textSize="15pt"
    57         android:layout_width="fill_parent"
    58         android:layout_height="wrap_content"
    59         android:layout_weight="1"/>
    60     <TextView
    61         android:text="row three"
    62         android:textSize="15pt"
    63         android:layout_width="fill_parent"
    64         android:layout_height="wrap_content"
    65         android:layout_weight="1"/>
    66     <TextView
    67         android:text="row four"
    68         android:textSize="15pt"
    69         android:layout_width="fill_parent"
    70         android:layout_height="wrap_content"
    71         android:layout_weight="1"/>
    72        </LinearLayout>
    73 </LinearLayout>

    TableLayout:

     1 <?xml version="1.0" encoding="utf-8"?>
     2 <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
     3     android:layout_width="fill_parent"
     4     android:layout_height="fill_parent"
     5     android:stretchColumns="0">
     6     <TableRow>
     7         <TextView
     8             android:text="@string/row1_column1"
     9             android:background="#aa0000"
    10             android:padding="3dip" />
    11         <TextView
    12             android:text="@string/row1_column1"
    13             android:padding="3dip"
    14             android:gravity="center_horizontal"
    15             android:background="#00aa00"
    16             ></TextView>
    17         <TextView
    18             android:text="@string/row1_column2"
    19             android:gravity="right"
    20             android:background="#0000aa"
    21             android:padding="3dip" />
    22     </TableRow>
    23 
    24     <TableRow>
    25         <TextView
    26             android:text="@string/row2_column1"
    27             android:padding="3dip" />
    28         <TextView
    29             android:text="@string/row2_column2"
    30             android:gravity="right"
    31             android:padding="3dip" />
    32     </TableRow>
    33 </TableLayout>

    RealitiveLayout:

     1 <?xml version="1.0" encoding="utf-8"?>
     2     <!--
     3         android:layout_above 将该控件的底部至于给定ID的控件之上
     4         android:layout_below 将该控件的顶部至于给定ID的控件之下
     5         android:layout_toLeftOf 将该控件的右边缘和给定ID的控件的左边缘对齐
     6         android:layout_toRightOf 将该控件的左边缘和给定ID的控件的右边缘对齐
     7 
     8         android:layout_alignBaseline 该控件的baseline和给定ID的控件的baseline对齐
     9         android:layout_alignBottom 将该控件的底部边缘与给定ID控件的底部边缘
    10         android:layout_alignLeft 将该控件的左边缘与给定ID控件的左边缘对齐
    11         android:layout_alignRight 将该控件的右边缘与给定ID控件的右边缘对齐
    12         android:layout_alignTop 将给定控件的顶部边缘与给定ID控件的顶部对齐
    13 
    14 
    15         android:alignParentBottom 如果该值为true,则将该控件的底部和父控件的底部对齐
    16         android:layout_alignParentLeft 如果该值为true,则将该控件的左边与父控件的左边对齐
    17         android:layout_alignParentRight 如果该值为true,则将该控件的右边与父控件的右边对齐
    18         android:layout_alignParentTop 如果该值为true,则将空间的顶部与父控件的顶部对齐
    19 
    20         android:layout_centerHorizontal 如果值为真,该控件将被至于水平方向的中央
    21         android:layout_centerInParent 如果值为真,该控件将被至于父控件水平方向和垂直方向的中央
    22         android:layout_centerVertical 如果值为真,该控件将被至于垂直方向的中央
    23     -->
    24 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    25                 android:layout_width="fill_parent"
    26                 android:layout_height="wrap_content"
    27                 android:padding="10px" >
    28 
    29     <TextView android:id="@+id/label" 
    30               android:layout_width="fill_parent" 
    31               android:layout_height="wrap_content" 
    32               android:text="Type here:" />
    33 
    34     <EditText android:id="@+id/entry" 
    35               android:layout_width="fill_parent" 
    36               android:layout_height="wrap_content" 
    37               android:background="@android:drawable/editbox_background"
    38               android:layout_below="@id/label" />
    39   
    40     <Button android:id="@+id/ok" 
    41             android:layout_width="wrap_content" 
    42             android:layout_height="wrap_content" 
    43             android:layout_below="@id/entry"
    44             android:layout_alignParentRight="true"
    45             android:layout_marginLeft="10px"
    46             android:text="OK" />
    47 
    48     <Button android:layout_width="wrap_content" 
    49             android:layout_height="wrap_content"
    50             android:layout_toLeftOf="@id/ok"
    51             android:layout_alignTop="@id/ok"
    52             android:text="Cancel" />
    53 </RelativeLayout>
  • 相关阅读:
    c++中vector的用法详解[转]
    C++ String
    va_list用法
    如何高效的分析AWR报告
    Oracle存储过程跟踪错误的方法
    Oracle找出锁,并KILL掉
    OracleAWR报告概念和生成
    Linux系统的内存管理
    AIX系统下配置FTP服务
    通过修改注册表配置IE选项
  • 原文地址:https://www.cnblogs.com/humanchan/p/3020812.html
Copyright © 2011-2022 走看看