Android相对布局实例

<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>

  运行结果:

时间: 2024-08-01 10:27:58

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

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

Android:布局实例之模仿QQ登录界面 预览图: 准备: 1.找到模仿对象 QQ登陆界面UI下载>>>>> 2.导入工程 3.查看布局结构和使用控件 其对应效果图分布为 4.分析样式选择器 下拉箭头2种样式:点击和默认状态 文本框2种样式:聚焦和默认状态 复选框3种样式:选择.不选择和鼠标点着不放 左下角按钮2种样式:点击和默认 登录按钮2样式:点击和默认 ============================================帖代码===========

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

预览图及布局结构参考: 布局: 1 <?xml version="1.0" encoding="utf-8"?> 2 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 android:layout_width="match_parent" 4 android:layout_height="matc

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

实现效果: 整理思路: 1.控件:文字TextView 和 右箭头ImageView 2.因为考虑到点击效果,设计为:最外层为全圆角,内层有四种情况,分别为上圆角.无圆角.下圆角和全圆角. 3.内层样式效果:需要初始样式.和点击样式 4.需要知识:结合style.shake.selector组合样式 布局: 1 <?xml version="1.0" encoding="utf-8"?> 2 <LinearLayout xmlns:android=

android widget 开发实例 : 桌面便签程序的实现具体解释和源代码 (上)

如有错漏请不吝拍砖指正,转载请注明出处,很感谢 桌面便签软件是android上经常使用软件的一种,比方比較早的Sticky Note,就曾很流行, Sticky Note的介绍能够參见 http://www.tompda.com/c/article/11778/ 而实际上使用android平台对widget开发的支持,桌面便签类软件是很易于开发的. 本文通过逐步实现一个简单的桌面便签软件,和大家分享进行widget开发的过程和方法. 1.MyNote的终于实现效果 为了提起大家阅读本文的兴趣,先

布局实例:用表格布局实现计算器布局

预览效果: <?xml version="1.0" encoding="utf-8"?> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" androi

Android Widget 开发实例:桌面便签程序的实现详解和源码

桌面便签软件是Android上常用软件的一种,比如比较早的Sticky Note,就曾非常流行,而实际上使用android平台对widget开发的支持,桌面便签类软件是非常易于开发的. 本文通过逐步实现一个简单的桌面便签软件,和大家分享进行widget开发的过程和方法. 同时本程序提供完整的工程源码下载 免费下载地址在 http://linux.linuxidc.com/ 用户名与密码都是www.linuxidc.com 具体下载目录在 /pub/Android源码集锦/2011年/10月/An

android 用户界面教程实例汇总

1.android用户界面之WebView教程实例汇总http://www.apkbus.com/android-51718-1-1.html 2.android用户界面之Notification教程实例汇总http://www.apkbus.com/android-51696-1-1.html 3.android用户界面之Widget教程实例汇总http://www.apkbus.com/android-51674-1-1.html 4.android用户界面之Gallery教程实例汇总htt

Android减少布局层次--有关Activity根视图DecorView的思考

1 前面文章里面总结的一张图 一直觉得有关DecorView还是有些问题没有搞清楚,今天在看了一点有关SurfaceFlinger的内容以后,顿时突发奇想,想到之前的问题,之前的思考是: 虽然可以将DecorView作为Activity布局的父View,也就是只存在  DecorView---->Activity Layout两层,但是经过试验还是会存在Title Bar,或者说是现在的Action Bar,尝试如下: protected void onCreate(Bundle savedIn

Android 上千实例源码分析以及开源分析

Android 上千实例源码分析以及开源分析(百度云分享) 要下载的直接翻到最后吧,项目实例有点多. 首先 介绍几本书籍(下载包中)吧. 01_Android系统概述 02_Android系统的开发综述 03_Android的Linux内核与驱动程序 04_Android的底层库和程序 05_Android的JAVA虚拟机和JAVA环境 06_Android的GUI系统 07_Android的Audio系统 08_Android的Video 输入输出系统 09_Android的多媒体系统 10_