<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.fingergame.MainActivity"
tools:ignore="MergeRootFrame" >
<!-- 注释不能写在</>标记内 -->
<!-- android:layout_width="fill_parent"这与父组件左右对齐属性结合的效果一致-->
<TextView
android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:gravity="center_horizontal"
android:textSize="20sp"
android:textColor="#0000FF"
android:text="猜 拳 游 戏"
/> <ImageView
android:id="@+id/photo1"
android:layout_below="@id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="18dp"
android:layout_marginLeft="60dp"
android:src="@drawable/smileface"
/> <ImageView
android:id="@+id/photo2"
android:layout_below="@id/title"
android:layout_toRightOf="@id/photo1"
android:layout_marginTop="18dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="80dp"
android:src="@drawable/smileface"
/>
<RadioGroup
android:id="@+id/chose1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="18dp"
android:layout_marginLeft="40dp"
android:layout_below="@id/photo1"
android:orientation="vertical"
> <RadioButton
android:id="@+id/stone1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/photo1"
android:layout_toRightOf="@+id/chose1"
android:layout_marginTop="20dp"
android:checked="true"
android:text="石头" /> <RadioButton
android:id="@+id/scissors1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/stone1"
android:layout_marginTop="20dp"
android:layout_toRightOf="@+id/chose1"
android:text="剪刀" /> <RadioButton
android:id="@+id/cloth1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/scissors1"
android:layout_marginTop="20dp"
android:layout_toRightOf="@+id/chose1"
android:text="布" />
</RadioGroup> <!-- android:layout_height="wrap_content"以chose1的头部对齐
比用android:layout_marginTop="20dp"更灵活 -->
<RadioGroup
android:id="@+id/chose2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/chose1"
android:layout_marginLeft="70dp"
android:layout_toRightOf="@+id/photo1"
android:orientation="vertical" > <RadioButton
android:id="@+id/stone2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/chose1"
android:layout_marginTop="20dp"
android:layout_toRightOf="@+id/stone1"
android:checked="true"
android:text="石头" /> <RadioButton
android:id="@+id/scissors2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/stone2"
android:layout_marginTop="20dp"
android:layout_toRightOf="@+id/scissors1"
android:text="剪刀" /> <RadioButton
android:id="@+id/cloth2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/cloth1"
android:layout_marginTop="20dp"
android:layout_toRightOf="@+id/cloth1"
android:text="布" />
</RadioGroup> <Button
android:id="@+id/ok1"
android:layout_width="75dp"
android:layout_height="35dp"
android:layout_below="@+id/chose1"
android:layout_marginTop="20dp"
android:layout_alignLeft="@+id/chose1"
android:text="确认"
/> <Button
android:id="@+id/ok2"
android:layout_width="75dp"
android:layout_height="35dp"
android:layout_below="@+id/chose2"
android:layout_marginTop="20dp"
android:layout_alignLeft="@+id/chose2"
android:text="确认"
/> <TextView
android:id="@+id/copyright"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="5dp"
android:text="©fingergame 2015 | designer:Amy" /> </RelativeLayout>

  运行结果:

Android相对布局实例的更多相关文章

  1. [转]Android:布局实例之模仿QQ登录界面

    Android:布局实例之模仿QQ登录界面 预览图: 准备: 1.找到模仿对象 QQ登陆界面UI下载>>>>> 2.导入工程 3.查看布局结构和使用控件 其对应效果图分布 ...

  2. Android:布局实例之模仿QQ登录界面

    预览图: 准备: 1.找到模仿对象 QQ登陆界面UI下载>>>>> 2.导入工程 3.查看布局结构和使用控件 其对应效果图分布为 4.分析样式选择器 下拉箭头2种样式:点 ...

  3. Android:布局实例之模仿京东登录界面

    预览图及布局结构参考: 布局: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout ...

  4. Android:布局实例之模仿微信Tab

    微信Tab预览效果: 思路: 1.用TabHost+RadioGroup搭建基本布局,以RadioGroup代替TabWidget 2.设置按钮和文字的的样式和selector 3.创建相应的Acti ...

  5. Android:布局实例之常见用户设置界面

    实现效果: 整理思路: 1.控件:文字TextView 和 右箭头ImageView 2.因为考虑到点击效果,设计为:最外层为全圆角,内层有四种情况,分别为上圆角.无圆角.下圆角和全圆角. 3.内层样 ...

  6. Android:布局合集

    本文归纳Android布局中所用到的知识点,网络上的教程说得太细化,而对于前端来说,下面的归纳最适合不过了. Android五大布局: LinearLayout 线性布局 Relativelayout ...

  7. Android基本布局

    android基本布局有三种:LinearLayout,RelativeLayout,FrameLayout. 一.LinearLayout 1,这是一种垂直布局(或者水平布局),可以通过下面这一句来 ...

  8. Android课程---布局管理器中的线性布局

    线性布局实例: <?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:andro ...

  9. Android开发--布局二

    1.Andrid:控件布局(表格布局)TableLayout 有多少个TableRow对象就有多少行, 列数等于最多子控件的TableRow的列数 直接在TableLayout加控件,控件会占据一行 ...

随机推荐

  1. SQL Server xtype

    sysobjects 表 在数据库内创建的每个对象(约束.默认值.日志.规则.存储过程等)在表中占一行.只有在 tempdb 内,每个临时对象才在该表中占一行. 列名 数据类型 描述 name sys ...

  2. 关于使用"/"来 dispatcherServlet 的url-pattern带来的问题

    之前一直使用*.do来做的,但是绝的*.do很丑,于是就改用"/"来配置: <servlet> <servlet-name>dispatcherServle ...

  3. LeetCode Shortest Word Distance III

    原题链接在这里:https://leetcode.com/problems/shortest-word-distance-iii/ 题目: This is a follow up of Shortes ...

  4. Windows 下用 gogs 配置局域网 git server

    大道曙光 Windows 下用 gogs 配置局域网 git server 最近要用 C# 开发一个新的项目,所以需要在 Windows 局域网环境下构建一个 git server. 在 Window ...

  5. 浅谈负载均衡SLB、CLB和综合应用

    SLB     服务器负载均衡(Server Load Balancing),可以看作HSRP(热备份路由器协议)的扩展,实现多个服务器之间的负载均衡.     虚拟服务器代表的是多个真实服务器的群集 ...

  6. 电量显示Binding Converter MVVM

    用一个ProcessBar显示电量,低于20%时候,ForeGround为红色,否则为绿色, 页面使用了MVVM绑定到了ViewModel, ProcessBar XAML为 <Progress ...

  7. VMware设置共享文件夹

    第一步:安装vmware-tools

  8. lib3ds类库

    lib3ds类库 /* * The 3D Studio File Format Library * Copyright (C) 1996-2007 by Jan Eric Kyprianidis &l ...

  9. bootstrap实战经验

    凡是基本的布局需要float实现的,都可以考虑利用网格布局. 1,.jumbotron可以形成一个青灰色的背景,并自动调节对应边距 2,.panel的应用十分广泛,可以自动设置合适的padding.甚 ...

  10. 帮你深入理解OAuth2.0协议

    1. 引言 如果你开车去酒店赴宴,你经常会苦于找不到停车位而耽误很多时间.是否有好办法可以避免这个问题呢?有的,听说有一些豪车的车主就不担心这个问题.豪车一般配备两种钥匙:主钥匙和泊车钥匙.当你到酒店 ...