一:相对布局(RelativeLayout)

二:相对布局属性

三:效果图

四:样式(Values下的styles.xml)

 <style name="ButtonStyle" ><item name="android:radius">10dp</item><item name="android:textStyle">bold</item><item name="android:textSize">20sp</item><item name="android:color">#000</item><item name="android:borderlessButtonStyle">@style/TextAppearance.AppCompat.Body1</item></style>

五:布局代码

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical"android:layout_width="match_parent"android:layout_height="match_parent">
<TextViewandroid:textStyle="bold"android:paddingLeft="30dp"android:rotation="180"android:textSize="100sp"android:text="0"android:id="@+id/content"android:layout_alignParentTop="true"android:layout_alignParentLeft="true"android:layout_width="match_parent"android:layout_height="200dp" /><RelativeLayoutandroid:layout_below="@id/content"android:layout_width="match_parent"android:layout_height="match_parent"><Buttonandroid:layout_marginTop="10dp"style="@style/ButtonStyle"android:layout_marginLeft="10dp"android:id="@+id/btn_c"android:text="C"android:layout_width="90dp"android:layout_height="90dp" /><Buttonandroid:layout_marginTop="10dp"style="@style/ButtonStyle"android:layout_marginLeft="10dp"android:id="@+id/btn_delete"android:text="←"android:layout_toRightOf="@+id/btn_c"android:layout_width="90dp"android:layout_height="90dp" /><Buttonandroid:layout_marginTop="10dp"style="@style/ButtonStyle"android:layout_marginLeft="10dp"android:id="@+id/btn_SeekSurplus"android:layout_toRightOf="@+id/btn_delete"android:layout_width="90dp"android:layout_height="90dp"android:text="%" /><Buttonandroid:layout_marginTop="10dp"style="@style/ButtonStyle"android:id="@+id/btn_division"android:layout_marginLeft="10dp"android:layout_toRightOf="@+id/btn_SeekSurplus"android:text="÷"android:layout_width="90dp"android:layout_height="90dp" /><Buttonandroid:layout_marginTop="10dp"style="@style/ButtonStyle"android:layout_marginLeft="10dp"android:id="@+id/btn_7"android:text="7"android:layout_below="@+id/btn_c"android:layout_width="90dp"android:layout_height="90dp" /><Buttonandroid:layout_marginTop="10dp"style="@style/ButtonStyle"android:layout_marginLeft="10dp"android:id="@+id/btn_8"android:text="8"android:layout_toRightOf="@+id/btn_7"android:layout_below="@+id/btn_delete"android:layout_width="90dp"android:layout_height="90dp" /><Buttonandroid:layout_marginTop="10dp"style="@style/ButtonStyle"android:layout_marginLeft="10dp"android:id="@+id/btn_9"android:layout_below="@+id/btn_SeekSurplus"android:layout_toRightOf="@+id/btn_8"android:layout_width="90dp"android:layout_height="90dp"android:text="9" /><Buttonandroid:layout_marginTop="10dp"style="@style/ButtonStyle"android:id="@+id/btn_multiplication"android:layout_marginLeft="10dp"android:layout_toRightOf="@+id/btn_9"android:layout_below="@+id/btn_division"android:text="×"android:layout_width="90dp"android:layout_height="90dp" /><Buttonandroid:layout_marginTop="10dp"style="@style/ButtonStyle"android:layout_marginLeft="10dp"android:id="@+id/btn_4"android:text="4"android:layout_below="@+id/btn_7"android:layout_width="90dp"android:layout_height="90dp" /><Buttonandroid:layout_marginTop="10dp"style="@style/ButtonStyle"android:layout_marginLeft="10dp"android:id="@+id/btn_5"android:text="5"android:layout_toRightOf="@+id/btn_7"android:layout_below="@+id/btn_8"android:layout_width="90dp"android:layout_height="90dp" /><Buttonandroid:layout_marginTop="10dp"style="@style/ButtonStyle"android:layout_marginLeft="10dp"android:id="@+id/btn_6"android:layout_below="@+id/btn_9"android:layout_toRightOf="@+id/btn_8"android:layout_width="90dp"android:layout_height="90dp"android:text="6" /><Buttonandroid:layout_marginTop="10dp"style="@style/ButtonStyle"android:id="@+id/btn_Sub"android:layout_marginLeft="10dp"android:layout_toRightOf="@+id/btn_9"android:layout_below="@+id/btn_multiplication"android:text="-"android:layout_width="90dp"android:layout_height="90dp" /><Buttonandroid:layout_marginTop="10dp"style="@style/ButtonStyle"android:layout_marginLeft="10dp"android:id="@+id/btn_1"android:text="1"android:layout_below="@+id/btn_4"android:layout_width="90dp"android:layout_height="90dp" /><Buttonandroid:layout_marginTop="10dp"style="@style/ButtonStyle"android:layout_marginLeft="10dp"android:id="@+id/btn_2"android:text="2"android:layout_toRightOf="@+id/btn_7"android:layout_below="@+id/btn_5"android:layout_width="90dp"android:layout_height="90dp" /><Buttonandroid:layout_marginTop="10dp"style="@style/ButtonStyle"android:layout_marginLeft="10dp"android:id="@+id/btn_3"android:layout_below="@+id/btn_6"android:layout_toRightOf="@+id/btn_8"android:layout_width="90dp"android:layout_height="90dp"android:text="3" /><Buttonandroid:layout_marginTop="10dp"style="@style/ButtonStyle"android:id="@+id/btn_add"android:layout_marginLeft="10dp"android:layout_toRightOf="@+id/btn_9"android:layout_below="@+id/btn_Sub"android:text="+"android:layout_width="90dp"android:layout_height="90dp" /><Buttonandroid:layout_marginTop="10dp"style="@style/ButtonStyle"android:layout_marginLeft="10dp"android:id="@+id/btn_0"android:text="0"android:layout_below="@+id/btn_2"android:layout_width="90dp"android:layout_height="90dp" /><Buttonandroid:layout_marginTop="10dp"style="@style/ButtonStyle"android:layout_marginLeft="10dp"android:id="@+id/btn_little"android:text="."android:layout_toRightOf="@+id/btn_7"android:layout_below="@+id/btn_3"android:layout_width="90dp"android:layout_height="90dp" /><Buttonandroid:layout_marginTop="10dp"style="@style/ButtonStyle"android:layout_marginRight="10dp"android:layout_marginLeft="10dp"android:id="@+id/btn_equle"android:layout_below="@+id/btn_add"android:layout_toRightOf="@+id/btn_8"android:layout_width="match_parent"android:layout_height="90dp"android:text="=" /><Buttonstyle="@style/ButtonStyle"android:layout_marginLeft="10dp"android:layout_toRightOf="@+id/btn_9"android:layout_below="@+id/btn_add"android:text="0"android:layout_width="0dp"android:layout_height="wrap_content" /></RelativeLayout>
</RelativeLayout>

相关学习链接:
菜鸟编程网相对布局教程链接

Android实现计算器布局(相对布局)相关推荐

  1. Android UI详解之布局管理器(一)

    Android UI详解之布局管理器 一.布局管理器 ①顶级父类View ②子类GroupView ③AbsoluteLayout.FrameLayout.LinearLayout.GridLayou ...

  2. Android中常见五种布局管理器——RelativeLayout、LinearLayout、FrameLayout、TableLayout、GridLayout

    目录 布局管理器 RelativeLayout 常见属性 Relative的实践操作(实现软件更新界面) LinearLayout 常见属性 LinearLayout的实践操作(模范登录以及微信底部) ...

  3. Android 改变窗口标题栏的布局

    Android改变窗口标题栏的布局  第一种方式 --在XML文件里面引入配置文件作为标题. 第二种方式  --动态的代码加入进去. 第三种方式(网上的): 一. 重点 一般应用的Title都是建立应 ...

  4. android 分组 listview,Android实现的ListView分组布局改进示例

    本文实例讲述了android实现的listview分组布局改进方法.分享给大家供大家参考,具体如下: 由于是在网上转载的一篇文章,在这里就不多说废话了,首先看一下最终的效果图: 然后是实现该listv ...

  5. Android学习笔记(11):线性布局LinearLayout

    线性布局LinearLayout是指在横向或是竖向一个接一个地排列.当排列的组件超出屏幕后,超出的组件将不会再显示出来. LinearLayout支持的XML属性和相应方法如表所看到的: Attrib ...

  6. android 自定义event,Android运用onTouchEvent自定义滑动布局

    写在自定义之前 我们也许会遇到,自定义控件的触屏事件处理,先来了解一下View类中的,onTouch事件和onTouchEvent事件. 1.boolean onTouch(View v, Motio ...

  7. Android中使用ViewStub提高布局性能

    2019独角兽企业重金招聘Python工程师标准>>> 注,关于Stub的解释:在Java中,桩(stub)是指用来代替关联代码或者未实现代码的代码. ViewStub使用场景 如上 ...

  8. 【Android 应用开发】UI绘制流程 ( 生命周期机制 | 布局加载机制 | UI 绘制流程 | 布局测量 | 布局摆放 | 组件绘制 | 瀑布流布局案例 )

    文章目录 一. 博客相关资料 及 下载地址 1. 代码查看方法 ( ① 直接获取代码 | ② JAR 包替换 ) 2. 本博客涉及到的源码查看说明 二. Activity 生命周期回调机制 1. An ...

  9. android中的5个布局方式

    Android中常用的5大布局方式有以下几种: 线性布局(LinearLayout):按照垂直或者水平方向布局的组件. 帧布局(FrameLayout):组件从屏幕左上方布局组件. 表格布局(Tabl ...

  10. android界面布局题,【填空题】Android 系统中, 用于定义布局显示在界面上的风格。...

    [填空题]Android 系统中, 用于定义布局显示在界面上的风格. 更多相关问题 [37]A.anotherB.each otherC.the otherD.one another Tabor ma ...

最新文章

  1. excel图表交互联动_如何使用高大上的多级联动交互式图表来分析人员结构?
  2. 使用异步 I/O 大大提高应用程序的性能
  3. 数据库中字段类型对应的C#中的数据类型
  4. AutoML Challenge 历史回顾
  5. 实验4 贪心法(作业调度问题)
  6. Python3.6全栈开发实例[005]
  7. 速领,我给大家做了程序员专属红包封面~
  8. android 透明主题 crash,Android 8.0 的填坑(透明的activity崩溃)
  9. 20届美团提前批面经
  10. break 退出循环
  11. cocos2d-html5 仿微信打飞机游戏
  12. C#——SqlParameter的使用方法及注意事项
  13. .NET方面的框架的整理和总结
  14. 今日头条,即将崛起为中国互联网第三极
  15. 正则匹配某字符前的内容
  16. 中国一百大姓,您排第几?
  17. 万字详文告诉你如何做 Code Review!
  18. [机缘参悟-86]:清心寡欲,世外修行 ?负剑下山,闯荡江湖?
  19. 模拟病人排队看病过程c语言,模拟病人到医院排队看病上机内容完整实验报告.doc...
  20. aix 磁带机增量备份

热门文章

  1. 思科CEO自爆:G20虚拟会议用的我家技术
  2. 【优化算法】混沌博弈优化算法(CGO)【含Matlab源码 1803期】
  3. 【三维路径规划】基于matlab A_star算法无人机三维路径规划(起终点障碍物可设置)【含Matlab源码 1321期】
  4. 【优化预测】基于matlab贝叶斯网络优化LSTM预测【含Matlab源码 1158期】
  5. 【图像压缩】基于matlab DCT变换图像压缩【含Matlab源码 804期】
  6. 【语音识别】基于matlab GUI声纹识别(带面板)【含Matlab源码 537期】
  7. 【图像边缘检测】基于matlab元胞自动机图像边缘检测【含Matlab源码 427期】
  8. 丢失模式不联网有用吗_2020互联网推广新模式,商家还不知道就out了
  9. python: 从txt文件中读入数组
  10. 中南大学计算机学院伍逸凡,关于公布2017年湖南省大学生力学竞赛等15项学科竞赛结果的通知...