【Android】使用LinearLayout实现计算器效果
来源:互联网 发布:mp3 编辑软件 mac 编辑:程序博客网 时间:2024/06/04 18:06
Ubuntu下截屏花了好长时间,最后设置的快捷键为Crtl+Alt+A
这个效果实际上是这么做的。
首先整个页面分为6个水平线性布局,最后一个占两行。外面那个大布局是垂直排列。
难点在于最后一个,将其分为两个水平线性布局,第一个又包含了两个布局(垂直排列),第二个就是等号按钮。
代码如下:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#FFFFFF" 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="match_parent" android:layout_height="wrap_content" /> </LinearLayout> <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> <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="C" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="+/-" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="/" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="*" /> </LinearLayout> <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> <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="4" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="5" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="6" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="+" /> </LinearLayout> <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="3" android:orientation="vertical" > <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="1" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="2" /> <Button android:layout_width="match_parent" 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>
- 【Android】使用LinearLayout实现计算器效果
- 使用线性布局LinearLayout实现类似计算器的效果
- Android linearlayout实现button的点击效果
- android LinearLayout半透明效果
- Android使用代码实现RelativeLayout,LinearLayout布局
- Android使用代码实现RelativeLayout,LinearLayout布局
- Android使用代码实现RelativeLayout,LinearLayout布局
- Android使用代码实现RelativeLayout,LinearLayout布局
- android LinearLayout 实现左右布局 app常见效果
- android---LinearLayout,listener的计算器小实例
- LinearLayout 结合android:layout_weight 计算器界面
- Android实现计算器布局(四种布局方式)之LinearLayout线性布局
- Android LinearLayout实现多行多列
- Android LinearLayout使用
- Android LinearLayout使用演示
- 09、Android开发基础之计算器点击效果的实现
- Android-使用SoundPool实现语音计算器
- tab按下效果,使用LinearLayout + ImageView.和LinearLayout + Button
- Apple Official Example for every control: UICatalog.xcodeproj
- 隐藏和覆盖
- SOAP消息的格式
- $.ajax not working in chrome but is working in firefox and IE
- 第十一周项目3-6-调用函数输出1000内的回文素数
- 【Android】使用LinearLayout实现计算器效果
- 判断字符串中的字符是否唯一
- 网站推广经验浅谈:如何转变外链的效果
- slidingMenu的使用
- Topcoder SRM 596
- 序列化类型为XX的对象时检测到循环引用
- .NET Chart(1)---创建最基本的图表(设计器方式)
- char型变量中能不能存贮一个中文汉字?为什么?
- 猎头解密互联网公司offer行情,网易游戏研发高达40W--IT薪资待遇