zoukankan      html  css  js  c++  java
  • 用四种布局实现发送信息的界面

    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="match_parent"
     5     android:layout_height="match_parent">
     6 
     7     <EditText
     8         android:layout_width="match_parent"
     9         android:layout_height="wrap_content"
    10         android:hint="To"/>
    11     <EditText
    12         android:layout_width="match_parent"
    13         android:layout_height="wrap_content"
    14         android:hint="Subject"/>
    15     <EditText
    16         android:layout_width="match_parent"
    17         android:layout_height="wrap_content"
    18         android:hint="Message"
    19         android:layout_weight="1"
    20         android:gravity="top"/>
    21     <LinearLayout
    22         android:layout_width="match_parent"
    23         android:layout_height="wrap_content">
    24         <Button
    25             android:layout_width="0dp"
    26             android:layout_height="wrap_content"
    27             android:layout_weight="1"
    28             android:text="close"
    29             android:textAllCaps="false"/>
    30         <Button
    31             android:layout_width="0dp"
    32             android:layout_height="wrap_content"
    33             android:layout_weight="1"
    34             android:text="send"/>
    35     </LinearLayout>
    36     <LinearLayout
    37         android:layout_width="match_parent"
    38         android:layout_height="wrap_content">
    39         <Button
    40             android:layout_width="0dp"
    41             android:layout_height="wrap_content"
    42             android:layout_weight="1"
    43             android:text="close"
    44             android:textAllCaps="false"
    45             android:onClick="close_OnClick"/>
    46         <Button
    47             android:layout_width="0dp"
    48             android:layout_height="wrap_content"
    49             android:layout_weight="1"
    50             android:text="send"
    51             android:onClick="bt_OnClick"/>
    52     </LinearLayout>
    53 </LinearLayout>
    RelativeLayout:
     1 <?xml version="1.0" encoding="utf-8"?>
     2 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     3     android:layout_width="match_parent"
     4     android:layout_height="match_parent">
     5 
     6     <EditText android:layout_width="match_parent"
     7         android:layout_height="wrap_content"
     8         android:hint="To:"
     9         android:id="@+id/et1"/>
    10     <EditText android:layout_width="match_parent"
    11         android:layout_height="wrap_content"
    12         android:hint="Subject:"
    13         android:layout_below="@id/et1"
    14         android:id="@+id/et2"/>
    15     <EditText android:layout_width="match_parent"
    16         android:layout_height="wrap_content"
    17         android:hint="Message:"
    18         android:gravity="top"
    19         android:layout_below="@id/et2"
    20         android:id="@+id/et3"/>
    21     <LinearLayout
    22         android:layout_width="match_parent"
    23         android:layout_height="wrap_content"
    24         android:layout_alignParentBottom="true"
    25         android:id="@+id/LL">
    26         <Button
    27             android:layout_width="0dp"
    28             android:layout_height="wrap_content"
    29             android:text="close"
    30             android:textAllCaps="false"
    31             android:layout_weight="1"/>
    32         <Button
    33             android:layout_width="0dp"
    34             android:layout_height="wrap_content"
    35             android:text="send"
    36             android:layout_weight="1"/>
    37     </LinearLayout>
    38 </RelativeLayout>
    TableLayout:
     1 <?xml version="1.0" encoding="utf-8"?>
     2 <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
     3     android:layout_width="match_parent"
     4     android:layout_height="match_parent"
     5     android:stretchColumns="0,1">
     6 
     7     <TableRow>
     8         <EditText android:layout_width="match_parent"
     9             android:layout_height="wrap_content"
    10             android:hint="To:"
    11             android:layout_span="2"/>
    12     </TableRow>
    13     <TableRow>
    14         <EditText android:layout_width="match_parent"
    15             android:layout_height="wrap_content"
    16             android:hint="Subject:"
    17             android:layout_span="2"/>
    18     </TableRow>
    19     <TableRow android:layout_weight="1">
    20         <EditText android:layout_width="match_parent"
    21             android:layout_height="match_parent"
    22             android:hint="Message:"
    23             android:gravity="top"
    24             android:layout_span="2"/>
    25     </TableRow>
    26     <TableRow>
    27         <Button
    28             android:layout_width="wrap_content"
    29             android:layout_height="wrap_content"
    30             android:text="close"
    31             android:textAllCaps="false"/>
    32         <Button
    33             android:layout_width="wrap_content"
    34             android:layout_height="wrap_content"
    35             android:text="send"/>
    36     </TableRow>
    37 </TableLayout>
    GridLayout:
     1 <?xml version="1.0" encoding="utf-8"?>
     2 <GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
     3     android:layout_width="match_parent"
     4     android:layout_height="match_parent"
     5     android:rowCount="4"
     6     android:columnCount="2">
     7 
     8     <EditText android:layout_width="match_parent"
     9         android:layout_height="wrap_content"
    10         android:hint="To:"
    11         android:layout_columnSpan="2"/>
    12     <EditText android:layout_width="match_parent"
    13         android:layout_height="wrap_content"
    14         android:hint="Subject:"
    15         android:layout_columnSpan="2"/>
    16     <EditText android:layout_width="match_parent"
    17         android:layout_height="wrap_content"
    18         android:hint="Message:"
    19         android:layout_columnSpan="2"
    20         android:layout_rowWeight="1"
    21         android:gravity="top"/>
    22     <Button
    23         android:layout_width="0dp"
    24         android:layout_height="wrap_content"
    25         android:text="close"
    26         android:textAllCaps="false"
    27         android:layout_columnWeight="1"/>
    28     <Button
    29         android:layout_width="0dp"
    30         android:layout_height="wrap_content"
    31         android:text="send"
    32         android:layout_columnWeight="1"/>
    33 </GridLayout>

    效果皆如图:

  • 相关阅读:
    一个面试问题的答案总结
    全局变量与局部变量的特点
    浮点数类型在内存当中是如何存储的
    常用的几种调用约定
    裸函数
    安卓活动的启动模式
    安卓的生命周期
    android中的内部存储与外部存储
    堆栈图学习汇编结束篇最后一个堆栈图的练习
    Android内部存储与外部存储的文件操作类
  • 原文地址:https://www.cnblogs.com/hanazawalove/p/5425307.html
Copyright © 2011-2022 走看看