线性布局Linerlayout-计算器布局实现
来源:互联网 发布:aynak.apk软件下载 编辑:程序博客网 时间:2024/05/21 17:44
今天把线性布局这个基本的概念和使用技巧又学习了一下。
有个技巧就是:
把整个界面划分成几块,然后这几块怎么摆放就是很easy的事情了。
同时要理解 wrap_content match_parent 这2个属性的含义。
match_parent :就是填充满父控件,父控件有多宽,多高,那它就有多宽多高。
wrap_content : 就是包裹内部的文字或者图片。 没有多余的空间,直接包裹住
<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:orientation="vertical" > <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <EditText android:id="@+id/msg" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout> <!-- Linerlayout 可以嵌套使用 --> <!-- 第一列 --> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="mc" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="m+" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="m-" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="mr" /> </LinearLayout> <!-- 第2列 --> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="C" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="+/-" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="/" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="*" /> </LinearLayout> <!-- 第3列 --> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="7" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="8" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="9" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="*" /> </LinearLayout> <!-- 第4列 --> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="4" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="5" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="6" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="-" /> </LinearLayout> <!-- 第5列 --> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="vertical" > <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="1" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="2" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="3" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <Button android:layout_width="0px" android:layout_height="wrap_content" android:layout_weight="2" android:text="0" /> <Button android:layout_width="0px" android:layout_height="wrap_content" android:layout_weight="1" android:text="." /> </LinearLayout> </LinearLayout> <LinearLayout android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="1" android:orientation="horizontal" > <Button android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:text="=" /> </LinearLayout> </LinearLayout></LinearLayout>
0 0
- 线性布局Linerlayout-计算器布局实现
- Linerlayout(线性布局)
- LinerLayout(线性布局)
- Android布局(1)--线性布局(LinerLayout)
- EALayout 第六节 LinerLayout线性布局器
- Android之Android布局管理:LinerLayout线性布局
- 深入浅出学习 Android之Android布局管理:LinerLayout线性布局
- 深入浅出学习 Android之Android布局管理:LinerLayout线性布局
- 线性布局小实现——计算器的简单布局
- 线性布局--简单计算器的布局
- Android实现计算器布局(四种布局方式)之LinearLayout线性布局
- 使用线性布局LinearLayout实现类似计算器的效果
- 11、从头学Android之Android布局管理:LinerLayout线性布局
- 11、从头学Android之Android布局管理:LinerLayout线性布局
- 计算器布局及其实现
- 网格布局实现计算器
- Android布局之LinerLayout点滴
- android线性布局之计算器界面设计
- 开始总结式学习
- Volley框架解析(二)-----Volley及RequestQueue解析
- Leetcode: Single Number
- zoj3822Domination 概率dp
- 【机器学习基础】Logistic回归基础
- 线性布局Linerlayout-计算器布局实现
- Git 使用
- IOS-ScorllView
- SQL语句统计每天、每月、每年的 数据
- odoo8-qweb report 制作pdf报表方法介绍
- 鸟哥的Linux私房菜5.1部分笔记:linux注销、x window与命令行模式的切换(新手接触linux)
- 汇编移位: SHL、SHR、SAL、SAR、ROL、ROR、RCL、RCR 汇编移位: SHL、SHR、SAL、SAR、ROL、ROR、RCL、RCR
- Linux下彻底卸载mysql数据库
- POJ 1836Alignment(DP最长上升子序列)