<?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>
布局样子
本文来自博客园,作者:观心静 ,转载请注明原文链接:https://www.cnblogs.com/guanxinjing/p/9708640.html
本文版权归作者和博客园共有,欢迎转载,但必须给出原文链接,并保留此段声明,否则保留追究法律责任的权利。
分类:
Android开发
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具