android 相对布局例子代码
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.prize.mydemo1.Main3Activity">
<RelativeLayout
android:id="@+id/relative1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF">
<!--layout_alignParentLeft 控件位置在布局左边-->
<!--layout_alignParentTop 控件位置在布局上面-->
<view
android:id="@+id/view1"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="#550000"
/>
<!--layout_below 当前控件在目标控件下面-->
<!--layout_alignRight 向目标控件右边对齐-->
<view
android:id="@+id/view2"
android:layout_width="50dp"
android:layout_height="match_parent"
android:layout_below="@+id/view1"
android:layout_alignRight="@+id/view1"
android:background="#FF2222"
/>
<!--layout_alignParentBottom 控件位置在布局的下面-->
<!--layout_toLeftOf 当前控件在目标控件的左边-->
<view
android:id="@+id/view3"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="@id/view2"
android:background="#FF7777"
/>
<!--layout_above 当前控件在目标控件的上面-->
<view
android:id="@+id/view4"
android:layout_width="50dp"
android:layout_height="0dp"
android:layout_above="@+id/view3"
android:layout_below="@+id/view1"
android:background="#FF8F44"/>
<view
android:id="@+id/view5"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_toLeftOf="@+id/view2"
android:layout_below="@id/view1"
android:layout_toRightOf="@id/view4"
android:background="#FFDA44"/>
<view
android:id="@+id/view6"
android:layout_width="50dp"
android:layout_height="match_parent"
android:layout_below="@+id/view5"
android:layout_above="@+id/view3"
android:layout_toLeftOf="@+id/view2"
android:background="#D6FF33"
/>
<view
android:id="@+id/view7"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_above="@+id/view3"
android:layout_toLeftOf="@+id/view6"
android:layout_toRightOf="@+id/view4"
android:background="#B4FF44"
/>
<view
android:id="@+id/view8"
android:layout_width="50dp"
android:layout_height="match_parent"
android:layout_above="@+id/view7"
android:layout_toRightOf="@+id/view4"
android:layout_below="@+id/view5"
android:background="#99FF55"
/>
<view
android:id="@+id/view9"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_below="@+id/view5"
android:layout_toLeftOf="@+id/view6"
android:layout_toRightOf="@+id/view8"
android:background="#44FF44"
/>
<view
android:id="@+id/view10"
android:layout_width="50dp"
android:layout_height="match_parent"
android:layout_toLeftOf="@+id/view6"
android:layout_below="@+id/view9"
android:layout_above="@+id/view7"
android:background="#55FF99"
/>
<view
android:id="@+id/view11"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_above="@+id/view7"
android:layout_toLeftOf="@+id/view10"
android:layout_toRightOf="@+id/view8"
android:background="#55FFDD"
/>
<view
android:id="@+id/view12"
android:layout_width="50dp"
android:layout_height="match_parent"
android:layout_above="@+id/view11"
android:layout_toRightOf="@+id/view8"
android:layout_below="@+id/view9"
android:background="#55DDFF"
/>
<view
android:id="@+id/view13"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_below="@id/view9"
android:layout_toRightOf="@+id/view12"
android:layout_toLeftOf="@+id/view10"
android:background="#44B4FF"
/>
</RelativeLayout>
</LinearLayout>
布局样子
android 相对布局例子代码的更多相关文章
- android studio布局文件/XML怎么代码补全
android studio中的布局文件代码补全方式是打第一个字母就提示了,而java代码有时候要按快捷键. 布局文件的话呢,要写在标签开始处才提示,在标签闭合处有时候不提示,有时候在内容里也会有不提 ...
- Android 使用纯Java代码布局
java布局 java代码布局和xml布局的区别 1.Java纯布局更加的灵活,比如自定义控件或一些特殊要求时,使用java代码布局 2.常用的xml布局是所见即所得的编写方式,以及xml本身拥有一些 ...
- 在Android中用纯Java代码布局
感谢大佬:https://www.jianshu.com/p/7aedea560f16 在Android中用纯Java代码布局 本文的完成了参考了一篇国外的教程,在此表示感谢. Android中的界面 ...
- 【腾讯Bugly干货分享】Android动态布局入门及NinePatchChunk解密
本文来自于腾讯bugly开发者社区,非经作者同意,请勿转载,原文地址:http://dev.qq.com/topic/57c7ff5d53bbcffd68c64411 作者:黄进——QQ音乐团队 摆脱 ...
- android的布局管理器
理论上通过setContentView(view)能够把一个view设置到activity中,但当你有很多个view控件的时候,就需要用android的布局管理器来管理view控件了. android ...
- Android 实现布局动态加载
Android 动态加载布局 通过使用LayoutInflater 每次点击按钮时候去读取布局文件,然后找到布局文件里面的各个VIEW 操作完VIEW 后加载进我们setContentView 方面里 ...
- Android相对布局(RelativeLayout)
Android相对布局(RelativeLayout) 备注:这里的视图和元素是等同的概念. RelativeLayout是一个允许子视图相对于其他兄弟视图或是父视图显示的视图组(通过ID指定).每个 ...
- Android的布局优化之include、merge 、viewstub
以前在写布局的时候总是喜欢用自己熟悉的方式去写,从来也没有想过优化怎么的,后来又一次在上班的时候老大拿着我写的一个页面说我这个不行.我说这不是和设计图上的一模一样的么?怎么就不行了?然后他就跟我说了一 ...
- 我的Android进阶之旅------>Android拍照小例子
今天简单的学习了一下android拍照的简单实现. 当然该程序是个小例子,非常简单,没有什么复杂的操作,但是可以学习到Android 拍照API流程. 1.在布局文件中添加一个 surfaceView ...
随机推荐
- Abp问题解决集合1
ABP学习经验 1. 视图中(控制器中直接使用仓储)会遇到使用实体外键,出现数据库连接关闭的错误 初学者经常会犯这样一个错误,没错说的就是我自己,这个问题折腾了我很长世间.还是没有细看文档,对ab ...
- 导入导出Excel文件
搭建环境 先新建web project ,然后Add Struts Capabilties: 下载导入导出Excel所需的jar包: poi-3.8-20120326.jar包 : http:// ...
- jQuery实现商品详情 详细参数页面切换
利用index实现: <!DOCTYPE html> <html lang="en"> <head> <meta charset=&quo ...
- Linux系统构成和基本操作
Linux的优势 Linux的目录结构 Linux目录与文件管理 列出目录内容 创建新目录(文件夹) 创建文件 复制文件或目录 删除文件或目录 移动目录或文件 查看文件属性 文件属性含义 读权限-4 ...
- URL中传递参数给视图函数
1. 采用在url中使用变量的方式: 在path的第一个参数中,使用<参数名>的方式可以传递参数.然后在视图函数中也要写一个参数,视图函数中的参数必须和url中的参数名称保持一致,不然就找 ...
- 找进程的窗口Handle
Process[] ProcessList = Process.GetProcessesByName("mspaint");//画图板 IntPtr test = ProcessL ...
- sql server 存储过程使用游标记录
sql server 存储过程使用游标记录--方便下次参考使用 游标的组成: 声明游标 打卡游标 从一个游标中查找信息 关闭游标 释放游标 游标类型: 静态游标 动态游标 只进游标 键集驱动游标 静态 ...
- 测试教程网.unittest教程.8. 断言异常
From: http://www.testclass.net/pyunit/assert_raise/ 背景 我们有时候需要断言一些方法会抛出异常,这些异常需要符合我们的预期. 代码 新建test_e ...
- python图片和字符串的转换
有个业务,需要将图片压缩转化为64位编码上传到服务端. import json,requests,base64 #网上下载图片素材 r = requests.get("https://tim ...
- 廖雪峰Java2面向对象编程-1面向对象-1面向对象基础
1.对象的概念 面向对象编程:Object-Oriented Programming 对现实世界建立计算机模型的一种编程方法. 现实世界 计算机模型 Java代码 人 类/class class Pe ...