经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » 移动开发 » Android » 查看文章
Android 线性布局 计算器
来源:cnblogs  作者:thomas_blog  时间:2019/11/4 8:29:26  对本文有异议
  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:layout_height="match_parent"
  5. android:background="#FFFFFF"
  6. android:orientation="vertical" >
  7.  
  8. <LinearLayout
  9. android:layout_width="match_parent"
  10. android:layout_height="wrap_content"
  11. android:orientation="horizontal" >
  12.  
  13. <EditText
  14. android:id="@+id/data"
  15. android:layout_width="match_parent"
  16. android:layout_height="wrap_content" />
  17. </LinearLayout>
  18.  
  19. <LinearLayout
  20. android:layout_width="match_parent"
  21. android:layout_height="wrap_content"
  22. android:orientation="horizontal" >
  23.  
  24. <Button
  25. android:layout_width="match_parent"
  26. android:layout_height="wrap_content"
  27. android:layout_weight="1"
  28. android:text="mc" />
  29.  
  30. <Button
  31. android:layout_width="match_parent"
  32. android:layout_height="wrap_content"
  33. android:layout_weight="1"
  34. android:text="m+" />
  35.  
  36. <Button
  37. android:layout_width="match_parent"
  38. android:layout_height="wrap_content"
  39. android:layout_weight="1"
  40. android:text="m-" />
  41.  
  42. <Button
  43. android:layout_width="match_parent"
  44. android:layout_height="wrap_content"
  45. android:layout_weight="1"
  46. android:text="mr" />
  47. </LinearLayout>
  48.  
  49. <LinearLayout
  50. android:layout_width="match_parent"
  51. android:layout_height="wrap_content"
  52. android:orientation="horizontal" >
  53.  
  54. <Button
  55. android:layout_width="match_parent"
  56. android:layout_height="wrap_content"
  57. android:layout_weight="1"
  58. android:text="C" />
  59.  
  60. <Button
  61. android:layout_width="match_parent"
  62. android:layout_height="wrap_content"
  63. android:layout_weight="1"
  64. android:text="+/-" />
  65.  
  66. <Button
  67. android:layout_width="match_parent"
  68. android:layout_height="wrap_content"
  69. android:layout_weight="1"
  70. android:text="/" />
  71.  
  72. <Button
  73. android:layout_width="match_parent"
  74. android:layout_height="wrap_content"
  75. android:layout_weight="1"
  76. android:text="*" />
  77. </LinearLayout>
  78.  
  79. <LinearLayout
  80. android:layout_width="match_parent"
  81. android:layout_height="wrap_content"
  82. android:orientation="horizontal" >
  83.  
  84. <Button
  85. android:layout_width="match_parent"
  86. android:layout_height="wrap_content"
  87. android:layout_weight="1"
  88. android:text="7" />
  89.  
  90. <Button
  91. android:layout_width="match_parent"
  92. android:layout_height="wrap_content"
  93. android:layout_weight="1"
  94. android:text="8" />
  95.  
  96. <Button
  97. android:layout_width="match_parent"
  98. android:layout_height="wrap_content"
  99. android:layout_weight="1"
  100. android:text="9" />
  101.  
  102. <Button
  103. android:layout_width="match_parent"
  104. android:layout_height="wrap_content"
  105. android:layout_weight="1"
  106. android:text="-" />
  107. </LinearLayout>
  108.  
  109. <LinearLayout
  110. android:layout_width="match_parent"
  111. android:layout_height="wrap_content"
  112. android:orientation="horizontal" >
  113.  
  114. <Button
  115. android:layout_width="match_parent"
  116. android:layout_height="wrap_content"
  117. android:layout_weight="1"
  118. android:text="4" />
  119.  
  120. <Button
  121. android:layout_width="match_parent"
  122. android:layout_height="wrap_content"
  123. android:layout_weight="1"
  124. android:text="5" />
  125.  
  126. <Button
  127. android:layout_width="match_parent"
  128. android:layout_height="wrap_content"
  129. android:layout_weight="1"
  130. android:text="6" />
  131.  
  132. <Button
  133. android:layout_width="match_parent"
  134. android:layout_height="wrap_content"
  135. android:layout_weight="1"
  136. android:text="+" />
  137. </LinearLayout>
  138.  
  139. <LinearLayout
  140. android:layout_width="match_parent"
  141. android:layout_height="wrap_content"
  142. android:orientation="horizontal" >
  143.  
  144. <LinearLayout
  145. android:layout_width="match_parent"
  146. android:layout_height="wrap_content"
  147. android:layout_weight="1"
  148. android:orientation="vertical" >
  149.  
  150. <LinearLayout
  151. android:layout_width="match_parent"
  152. android:layout_height="wrap_content"
  153. android:orientation="horizontal" >
  154.  
  155. <Button
  156. android:layout_width="match_parent"
  157. android:layout_height="wrap_content"
  158. android:layout_weight="1"
  159. android:text="1" />
  160.  
  161. <Button
  162. android:layout_width="match_parent"
  163. android:layout_height="wrap_content"
  164. android:layout_weight="1"
  165. android:text="2" />
  166.  
  167. <Button
  168. android:layout_width="match_parent"
  169. android:layout_height="wrap_content"
  170. android:layout_weight="1"
  171. android:text="3" />
  172. </LinearLayout>
  173.  
  174. <LinearLayout
  175. android:layout_width="match_parent"
  176. android:layout_height="wrap_content"
  177. android:orientation="horizontal" >
  178.  
  179. <Button
  180. android:layout_width="match_parent"
  181. android:layout_height="wrap_content"
  182. android:layout_weight="1"
  183. android:text="0" />
  184.  
  185. <Button
  186. android:layout_width="match_parent"
  187. android:layout_height="wrap_content"
  188. android:layout_weight="2"
  189. android:text="." />
  190. </LinearLayout>
  191. </LinearLayout>
  192.  
  193. <LinearLayout
  194. android:layout_width="match_parent"
  195. android:layout_height="match_parent"
  196. android:layout_weight="3" >
  197.  
  198. <Button
  199. android:layout_width="match_parent"
  200. android:layout_height="match_parent"
  201. android:text="=" />
  202. </LinearLayout>
  203. </LinearLayout>
  204.  
  205. </LinearLayout>

image

原文链接:http://www.cnblogs.com/zhangxuechao/p/11777081.html

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号