zoukankan      html  css  js  c++  java
  • Android 计算器布局测试1

    1 TableLayout(表格布局) 

    http://www.cnblogs.com/zhaoyucong/p/6101353.html

    http://www.cnblogs.com/UUUP/p/3983309.html

      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:stretchColumns="*"
      5     android:layout_height="match_parent" >
      6 
      7     <TextView
      8         android:layout_weight="1"
      9         android:id="@+id/TextView1"
     10         android:layout_width="wrap_content"
     11         android:layout_height="60dp"
     12         android:gravity="right|center_vertical"
     13         android:textSize="30sp"
     14         android:text="90"
     15         />
     16 
     17     <TableRow
     18         android:id="@+id/tableRow1"
     19         android:layout_weight="1"
     20         android:layout_width="wrap_content"
     21         android:layout_height="match_parent" >
     22 
     23         <Button
     24             android:id="@+id/button1"
     25             android:layout_width="wrap_content"
     26             android:layout_height="match_parent"
     27             android:textSize="25sp"
     28             android:text="7" />
     29 
     30         <Button
     31             android:id="@+id/button2"
     32             android:layout_width="wrap_content"
     33             android:textSize="25sp"
     34             android:layout_height="match_parent"
     35             android:text="8" />
     36 
     37         <Button
     38             android:id="@+id/button3"
     39             android:layout_width="wrap_content"
     40             android:textSize="25sp"
     41             android:layout_height="match_parent"
     42             android:text="9" />
     43 
     44         <Button
     45             android:id="@+id/button4"
     46             android:layout_width="wrap_content"
     47             android:layout_height="match_parent"
     48             android:textSize="25sp"
     49             android:text="/" />
     50 
     51     </TableRow>
     52 
     53     <TableRow
     54         android:id="@+id/tableRow2"
     55         android:layout_weight="1"
     56         android:layout_width="wrap_content"
     57         android:layout_height="match_parent" >
     58 
     59         <Button
     60             android:id="@+id/button5"
     61             android:textSize="25sp"
     62             android:layout_width="wrap_content"
     63             android:layout_height="match_parent"
     64             android:text="4" />
     65 
     66         <Button
     67             android:id="@+id/button6"
     68             android:textSize="25sp"
     69             android:layout_width="wrap_content"
     70             android:layout_height="match_parent"
     71             android:text="5" />
     72 
     73         <Button
     74             android:id="@+id/button7"
     75             android:textSize="25sp"
     76             android:layout_width="wrap_content"
     77             android:layout_height="match_parent"
     78             android:text="6" />
     79 
     80         <Button
     81             android:id="@+id/button8"
     82             android:textSize="25sp"
     83             android:layout_width="wrap_content"
     84             android:layout_height="match_parent"
     85             android:text="*" />
     86 
     87     </TableRow>
     88 
     89     <TableRow
     90         android:id="@+id/tableRow3"
     91         android:layout_weight="1"
     92         android:layout_width="wrap_content"
     93         android:layout_height="match_parent" >
     94 
     95         <Button
     96             android:id="@+id/button9"
     97             android:textSize="25sp"
     98             android:layout_width="wrap_content"
     99             android:layout_height="match_parent"
    100             android:text="1" />
    101 
    102         <Button
    103             android:id="@+id/button10"
    104             android:textSize="25sp"
    105             android:layout_width="wrap_content"
    106             android:layout_height="match_parent"
    107             android:text="2" />
    108 
    109         <Button
    110             android:textSize="25sp"
    111             android:id="@+id/button11"
    112             android:layout_width="wrap_content"
    113             android:layout_height="match_parent"
    114             android:text="3" />
    115 
    116         <Button
    117             android:id="@+id/button12"
    118             android:textSize="25sp"
    119             android:layout_width="wrap_content"
    120             android:layout_height="match_parent"
    121             android:text="-" />
    122 
    123     </TableRow>
    124 
    125     <TableRow
    126         android:id="@+id/tableRow4"
    127         android:layout_weight="1"
    128         android:layout_width="wrap_content"
    129         android:layout_height="match_parent" >
    130 
    131         <Button
    132             android:id="@+id/button13"
    133             android:layout_width="wrap_content"
    134             android:layout_height="match_parent"
    135             android:textSize="25sp"
    136             android:text="0" />
    137 
    138         <Button
    139             android:id="@+id/button14"
    140             android:layout_width="wrap_content"
    141             android:textSize="25sp"
    142             android:layout_height="match_parent"
    143             android:text="." />
    144 
    145         <Button
    146             android:id="@+id/button15"
    147             android:textSize="25sp"
    148             android:layout_width="wrap_content"
    149             android:layout_height="match_parent"
    150             android:text="+" />
    151 
    152         <Button
    153             android:id="@+id/button16"
    154             android:textSize="25sp"
    155             android:layout_width="wrap_content"
    156             android:layout_height="match_parent"
    157             android:text="=" />
    158 
    159     </TableRow>
    160 
    161     <TableRow
    162         android:id="@+id/tableRow5"
    163         android:layout_weight="1"
    164         android:layout_width="wrap_content"
    165         android:layout_height="match_parent" >
    166 
    167         <Button
    168             android:id="@+id/button17"
    169             android:layout_span="4"
    170             android:textSize="25sp"
    171             android:layout_width="wrap_content"
    172             android:layout_height="match_parent"
    173             android:text="clear" />
    174 
    175     </TableRow>
    176     
    177 </TableLayout>
    View Code

    2. 线性布局 http://blog.csdn.net/goodluckac/article/details/51954380

      1 <?xml version="1.0" encoding="utf-8"?>
      2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      3     android:layout_width="match_parent"
      4     android:orientation="vertical"
      5     android:layout_height="match_parent">
      6     <LinearLayout
      7         android:layout_width="match_parent"
      8         android:layout_weight="1"
      9         android:layout_height="wrap_content">
     10         <TextView
     11             android:layout_width="match_parent"
     12             android:layout_height="wrap_content"
     13             android:text="  99999999"
     14             android:textSize="35dp"/>
     15 
     16     </LinearLayout>
     17     <LinearLayout
     18         android:layout_width="match_parent"
     19         android:layout_weight="6"
     20         android:layout_height="wrap_content"
     21         android:orientation="vertical">
     22         <LinearLayout
     23             android:layout_width="match_parent"
     24             android:layout_height="wrap_content"
     25             android:layout_weight="4"
     26             android:orientation="vertical">
     27             <LinearLayout
     28                 android:layout_width="match_parent"
     29                 android:layout_height="0dp"
     30                 android:layout_weight="1">
     31                 <Button
     32                     android:layout_width="wrap_content"
     33                     android:layout_height="match_parent"
     34                     android:layout_weight="1"
     35                     android:text="mc" />
     36                 <Button
     37                     android:layout_width="wrap_content"
     38                     android:layout_height="match_parent"
     39                     android:layout_weight="1"
     40                     android:text="m+" />
     41                 <Button
     42                     android:layout_width="wrap_content"
     43                     android:layout_height="match_parent"
     44                     android:layout_weight="1"
     45                     android:text="m-" />
     46                 <Button
     47                     android:layout_width="wrap_content"
     48                     android:layout_height="match_parent"
     49                     android:layout_weight="1"
     50                     android:text="mr" />
     51             </LinearLayout>
     52             <LinearLayout
     53                 android:layout_width="match_parent"
     54                 android:layout_height="0dp"
     55                 android:layout_weight="1">
     56                 <Button
     57                     android:layout_width="wrap_content"
     58                     android:layout_height="match_parent"
     59                     android:layout_weight="1"
     60                     android:text="c" />
     61                 <Button
     62                     android:layout_width="wrap_content"
     63                     android:layout_height="match_parent"
     64                     android:layout_weight="1"
     65                     android:text="+/-" />
     66                 <Button
     67                     android:layout_width="wrap_content"
     68                     android:layout_height="match_parent"
     69                     android:layout_weight="1"
     70                     android:text="/" />
     71                 <Button
     72                     android:layout_width="wrap_content"
     73                     android:layout_height="match_parent"
     74                     android:layout_weight="1"
     75                     android:text="*" />
     76             </LinearLayout>
     77             <LinearLayout
     78                 android:layout_width="match_parent"
     79                 android:layout_height="0dp"
     80                 android:layout_weight="1">
     81                 <Button
     82                     android:layout_width="wrap_content"
     83                     android:layout_height="match_parent"
     84                     android:layout_weight="1"
     85                     android:text="7" />
     86                 <Button
     87                     android:layout_width="wrap_content"
     88                     android:layout_height="match_parent"
     89                     android:layout_weight="1"
     90                     android:text="8" />
     91                 <Button
     92                     android:layout_width="wrap_content"
     93                     android:layout_height="match_parent"
     94                     android:layout_weight="1"
     95                     android:text="9" />
     96                 <Button
     97                     android:layout_width="wrap_content"
     98                     android:layout_height="match_parent"
     99                     android:layout_weight="1"
    100                     android:text="-" />
    101 
    102             </LinearLayout>
    103             <LinearLayout
    104                 android:layout_width="match_parent"
    105                 android:layout_height="0dp"
    106                 android:layout_weight="1">
    107                 <Button
    108                     android:layout_width="wrap_content"
    109                     android:layout_height="match_parent"
    110                     android:layout_weight="1"
    111                     android:text="41" />
    112                 <Button
    113                     android:layout_width="wrap_content"
    114                     android:layout_height="match_parent"
    115                     android:layout_weight="1"
    116                     android:text="5" />
    117                 <Button
    118                     android:layout_width="wrap_content"
    119                     android:layout_height="match_parent"
    120                     android:layout_weight="1"
    121                     android:text="6" />
    122                 <Button
    123                     android:layout_width="wrap_content"
    124                     android:layout_height="match_parent"
    125                     android:layout_weight="1"
    126                     android:text="+" />
    127 
    128             </LinearLayout>
    129 
    130         </LinearLayout>
    131         <LinearLayout
    132             android:layout_width="match_parent"
    133             android:layout_height="0dp"
    134             android:layout_weight="2"
    135             android:orientation="horizontal">
    136             <LinearLayout
    137                 android:layout_width="0dp"
    138                 android:layout_height="match_parent"
    139                 android:layout_weight="3"
    140                 android:orientation="vertical">
    141                 <LinearLayout
    142                     android:layout_width="match_parent"
    143                     android:layout_height="0dp"
    144                     android:layout_weight="1">
    145                     <Button
    146                         android:layout_width="wrap_content"
    147                         android:layout_height="match_parent"
    148                         android:layout_weight="1"
    149                         android:text="1" />
    150                     <Button
    151                         android:layout_width="wrap_content"
    152                         android:layout_height="match_parent"
    153                         android:layout_weight="1"
    154                         android:text="2" />
    155                     <Button
    156                         android:layout_width="wrap_content"
    157                         android:layout_height="match_parent"
    158                         android:layout_weight="1"
    159                         android:text="3" />
    160                 </LinearLayout>
    161                 <LinearLayout
    162                     android:layout_width="match_parent"
    163                     android:layout_height="0dp"
    164                     android:layout_weight="1">
    165                     <Button
    166                         android:layout_width="wrap_content"
    167                         android:layout_height="match_parent"
    168                         android:layout_weight="1"
    169                         android:text="0" />
    170                     <Button
    171                         android:layout_width="wrap_content"
    172                         android:layout_height="match_parent"
    173                         android:layout_weight="1"
    174                         android:text="." />
    175                 </LinearLayout>
    176             </LinearLayout>
    177             <LinearLayout
    178                 android:layout_width="0dp"
    179                 android:layout_height="match_parent"
    180                 android:layout_weight="1"
    181                 >
    182                 <Button
    183                     android:layout_width="match_parent"
    184                     android:layout_height="match_parent"
    185                     android:text="=" />
    186             </LinearLayout>
    187         </LinearLayout>
    188     </LinearLayout>
    189 
    190 </LinearLayout>
    View Code
  • 相关阅读:
    使用 yo 命令行向导给 SAP UI5 应用添加一个新的视图
    SAP Fiori Elements 应用的 manifest.json 文件运行时如何被解析的
    SAP UI5 标准应用的多语言支持
    微软 Excel 365 里如何设置下拉菜单和自动高亮成指定颜色
    SAP Fiori Elements 应用里的 Title 显示的内容是从哪里来的
    本地开发好的 SAP Fiori Elements 应用,如何部署到 ABAP 服务器上?
    如何在 Cypress 测试代码中屏蔽(Suppress)来自应用代码报出的错误消息
    教你一招:让集群慢节点无处可藏
    应用架构步入“无服务器”时代 Serverless技术迎来新发展
    MySQL数据库事务隔离性的实现
  • 原文地址:https://www.cnblogs.com/hbuwyg/p/6994362.html
Copyright © 2011-2022 走看看