对于C#程序员来说布局不是什么难事,可是对于我这个新手在mono for android 中布局还是有点小纠结的,不会没关系。慢慢学习。好吧我们开始简单的布局。在之前我们拖拽的控件都是自动的去布局,也就是拖一个放一个。之间没有什么关系。都是上下那种简单的布局,那么如果一行当中我们要放两个按钮怎么办呢。首先我们在窗体先要放一个RelativeLayout 在这个当中有一个属性是用来控制窗体中的布局的。

在这个当中我们需要注意的是,如果没有用到RelativeLayout上面图片中的一些属性是不会出来的。
那下面我们来隆重介绍下他吧。
1.layout_above :设置当前控件在他上面控件的ID
2.layout_below:设置当前控件在他下面控件ID
3.layout_toLeftof:设置当前控件在他左边控件ID
4.layout_toRightof:设置当前控件在他右边控件ID
而ID设置的格式是:@id/ID名
由于刚刚学习暂时先写到这。互相学习。
下面是小小的一个窗体

源代码如下:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<EditText
android:id="@+id/txtPhoneNo"
android:layout_width="fill_parent"
android:phoneNumber="true"
android:hint="请输入电话号码"
android:layout_height="wrap_content"
android:layout_marginTop="5px"
android:layout_marginLeft="5px" />
<EditText
android:id="@+id/txtSMS"
android:layout_width="fill_parent"
android:layout_height="100dip"
android:singleLine="false"
android:gravity="top"
android:hint="请输入短信内容"
android:layout_below="@id/txtPhoneNo" />
<Button
android:id="@+id/btnDial"
android:text="拨打电话"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/txtSMS" />
<Button
android:id="@+id/btnSendSMS"
android:text="发送短信"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/txtSMS"
android:layout_toRightOf="@id/btnDial" />
<Button
android:id="@+id/btnSendEMail"
android:text="发送邮件"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/txtSMS"
android:layout_toRightOf="@id/btnSendSMS" />
<EditText
android:id="@+id/txtReceiver"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="请输入收件人"
android:layout_below="@id/btnDial" />
<EditText
android:id="@+id/txtTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="请输入邮件标题"
android:layout_below="@id/txtReceiver" />
<EditText
android:id="@+id/txtEMail"
android:layout_width="fill_parent"
android:layout_height="100dip"
android:gravity="top"
android:hint="请输入邮件正文"
android:layout_below="@id/txtTitle" />
</RelativeLayout>

转载自http://hi.baidu.com/zhou8237436/item/abd678c14ea2257889ad9e4e

mono for android 第三课--页面布局(转)的更多相关文章

  1. Mono for Android (1) 之布局

    最近和同事交接工作,首次接触mono for android, 结果画view时少了layout,页面没办法出来,各种冥思,各种找问题,最后把关于布局的一些共享出来(同事写的,哈哈):   Andro ...

  2. Android 第三课 构建简单的用户界面

    构建简单的用户界面 上一课下一课 该课程教你 创建线性布局 添加文本框 添加字符串资源 添加按钮 使输入框宽度充满整个屏幕 你也应该阅读 布局 Android的图形用户界面通过 View 和 View ...

  3. .Net程序猿乐Android开发---(4)注册页面布局

    接下来我们介绍的登陆页面布局,在本节中,我们看一下注册页面布局,页面布局大同小异,来一起熟悉下基本控件的使用方法. 效果图: 1.加入注冊页面 右键选中layout目录,加入注冊页面.例如以下图 点击 ...

  4. HTML5/CSS3 第三章页面布局

    页面布局 1 页面组成 2 布局相关的标签 <div></div> 定义文档中的分区或节 <span></span> 这是一个行内元素,没有任何意义 & ...

  5. .Net程序猿玩转Android开发---(3)登陆页面布局

    这一节我们来看看登陆页面如何布局.对于刚接触到Android开发的童鞋来说.Android的布局感觉比較棘手.须要结合各种属性进行设置,接下来我们由点入面来 了解安卓中页面如何布局,登陆页面非常eas ...

  6. android 开发 简单的页面布局

    package com.example.test; import android.app.Activity; import android.os.Bundle; import android.view ...

  7. mono for android 第四课--提示框(转)

    其实在VS中开发安卓代码和C#还是有一些相似性,刚开始我也不知道怎么弹出提示框,于是就百度了下,再加上个人的小聪明得到一下结果 builder.setTitle表示提示框的标题. setMessage ...

  8. HTML后台管理页面布局

    设计网页,让网页好看:网上找模板 搜 HTML模板 BootStrap 一.内容回顾: HTML 一大堆的标签:块级.行内 CSS position background text-align mar ...

  9. Asp.net MVC4高级编程学习笔记-视图学习第三课Razor页面布局20171010

    Razor页面布局 1)  在布局模板页中使用@RenderBody标记来渲染主要内容.比如很多web页面说头部和尾部相同,中间内容部分使用@RenderBody来显示不同的页面内容. 2)  在布局 ...

随机推荐

  1. 各大主流.Net的IOC框架性能测试比较(转)

    出处:http://www.cnblogs.com/liping13599168/archive/2011/07/17/2108734.html 在上一篇中,我简单介绍了下Autofac的使用,有人希 ...

  2. JMS规范简介

    一.JMS规范 Java消息服务定义: Java消息服务(Java Message Service)即JMS,是一个Java平台中面向消息中间件的API,用于在两个应用程序之间或分布式系统中发送/接受 ...

  3. c# Brush、Color、String相互转换

    using System.Windows.Media; 1.String转换成Color Color color = (Color)ColorConverter.ConvertFromString(s ...

  4. Git 客户端基本配置

    Welcome to Git (version -preview20140611) Run 'git help git' to display the help index. Run 'git hel ...

  5. CString->char*.,char*->CString,char*->LPCTSTR

    CString->char* CString strSource;//宣告CString char* charSource; //宣告char* 法1: charSource = (char*) ...

  6. 深入解析String#intern

    转自:https://tech.meituan.com/in_depth_understanding_string_intern.html 深入解析String#intern john_yang ·2 ...

  7. wp8.1 sqlite Error - Deployment optimization failed due to an assembly that's not valid.

    这里我们使用的sqlite的版本为3.8.5,vs2013在发布的时候出现 Error - Deployment optimization failed due to an assembly that ...

  8. vim 命令全

    1 简介 vim是文本编辑器.代码补完.编译及错误跳转等方便编程的功能特别丰富,在程序员中被广泛使用.下面讲述一些必要的基本命令,而掌握好这些命令,您就能够很容易将vim当作一个通用的万能编辑器来使用 ...

  9. EasyUI DataGrid 使用(分页,url数据获取,data转json)

    EasyUI算是比较有名的,搜一下网上的资料也比较多,具体的参数,下载地址我就不写了 平常也不怎么写文章,大部分都是代码,有不能运行的可以直接评论回复 有可能遇到的问题: json数据格式,这个要仔细 ...

  10. windows phone 8.0 app 移植到windows10 app笔记

    8.0 public class Convisibility : IValueConverter { public object Convert(object value, Type targetTy ...