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 ...
随机推荐
- 本地开发spark代码上传spark集群服务并运行
打包 :右击.export.Java .jar File 把TestSpark.jar包上传到spark集群服务器的 spark_home下的myApp下: 提交spark任务: cd /usr/lo ...
- 三重DEC加密在java中的实现
代码可以直接拷走使用,一些约定例如向量可以自行变动 引言 如今手机app五彩缤纷,确保手机用户的数据安全是开发人员必须掌握的技巧,下面通过实例介绍DES在android.ios.java平台 ...
- 使用Vivado进行行为级仿真
使用Vivado进行行为级仿真 1.编写设计文件 module test( input in, output out ); assign out = ~in; endmodule 2.编写testbe ...
- 安装centos7启动项配置
安装centos7启动项配置 1.将 setparams 'Install CentOS Linux 7' linuxefi/images/pxeboot/vmlinuz inst.stage2=hd ...
- VS2010与Qt5.1.0集成(非源码方式)
早就听说qt可以集成到VS中,就是一直没尝试过.一直在使用qt creator,也没觉得它有什么不好.可最近VS用多了,我发现一个qt creator中很不好的毛病,就是代码自动完成时,creator ...
- 在MacOSX系统上的一些工具和问题汇总
Android 模拟器 1. 安装模拟器 点击链接:https://cloud.genymotion.com/page/launchpad/download 需要先注册登录一下. 2.安装Virtua ...
- 【maven】之打包war依赖子项目jar
比如 p-common p-core p-dao p-service p-web service项目依赖dao,dao依赖core和common,web依赖service 在使用maven tomca ...
- JIRA 资源
https://www.**.com/article/2015/8/7/22532.html e_v_g_e_t JIRA使用教程:在Windows上安装JIRAJIRA使用教程:在Linux上安装J ...
- linux下recv 、send阻塞、非阻塞区别和用法
非阻塞IO 和阻塞IO: 在网络编程中对于一个网络句柄会遇到阻塞IO 和非阻塞IO 的概念, 这里对于这两种socket 先做一下说明: 基本概念: 阻塞IO:: socket 的阻塞模式 ...
- PAT 乙级 1069 微博转发抽奖(20) C++版
1069. 微博转发抽奖(20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 小明PAT考了满分,高兴之余决定 ...