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 ...
随机推荐
- mysql二进制日志详解
一.什么是二进制日志 二进制日志主要记录mysql数据库的变化,二进制日志包含所有更新了数据或者潜在更新了数据(如没有匹配到任何行的delete语句),语句以时间的形式保存,描述了数据的更改.二进制日 ...
- RedHat6.5创建本地yum源
拷贝Linux操作系统的rhel-server-6.5-x86_64-dvd.iso镜像到装好的Linux中: #执行挂载命令 mount –o loop /media/rhel-server-6.5 ...
- 【java】public,private和protected
public表示紧随其后的元素对任何人都是可用的,而private这个关键字表示除类型创建者和类型内部方法之外的任何人都不能访问的元素.protected关键字与private作用相当,差别仅在于继承 ...
- Consul+upsync+Nginx实现动态负载均衡 摘自https://blog.csdn.net/qq_29247945/article/details/80787014
传统感念:每次修改完nginx配置文件,要重启nginx 动态感念:每次修改完nginx配置信息,不需要重启,nginx实时读取配置信息. Nginx: 反向代理和负载均衡 Consul:是用go编写 ...
- GetClass与RegisterClass的应用一例
利用GetClass与RegisterClass可以实现根据字符串来实例化具体的子类,这对于某些需要动态配置程序的场合是很有用的.其他的应用如子窗体切换,算法替换等都能得到应用. unit Examp ...
- Hiero中的Events机制
The hiero.core.events module allows you to register method callbacks to respond to events sent by Hi ...
- 如何让classmethod只允许使用用类对象来调用
Django REST framework里面有这样一段代码,在网上查@classonlymethod的意思是使得classmethod只允许使用用类对象来调用 @classonlymethod de ...
- linux的系统组成和计算机组成原理,linux常用操作
Linux入门 linux简介 学习目的:linux服务器操作系统稳定长期运行,python,pycharm装于linux上 linux系统组成 应用软件:调用系统软件接口 linux操作系统分两 ...
- PREV-6_蓝桥杯_翻硬币
问题描述 小明正在玩一个“翻硬币”的游戏. 桌上放着排成一排的若干硬币.我们用 * 表示正面,用 o 表示反面(是小写字母,不是零). 比如,可能情形是:**oo***oooo 如果同时翻转左边的两个 ...
- elasticsearch 5.1 别的机器无法访问9200端口
版权声明:作者:jiankunking 出处:http://blog.csdn.net/jiankunking 本文版权归作者和CSDN共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显 ...