对于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. WebAPI请求(转)

    出处:http://www.cnblogs.com/babycool/p/3922738.html 继续接着上文 ASP.NET MVC学习系列(一)-WebAPI初探 来看看对于一般前台页面发起的g ...

  2. srping boot thymeleaf 学习总结 (2) - thymeleaf properties 国际化 mesaage

    thymeleaf获取配置properties中的数据与thymeleaf国际化(摘录) 使用thymeleaf提供的国际化 有时候会有直接在模板中获取配置文件properties中的配置信息,比如: ...

  3. Class 'App\Http\Controllers\DB' not found and I also cannot use a new Model

    使用laravel的db插入数据 DB::table('tags')->insert( ['name'=>'test'] ); 报错Class 'App\Http\Controllers\ ...

  4. Word2007发布博客

    目前大部分的博客作者在用Word写博客这件事情上都会遇到以下3个痛点: 1.所有博客平台关闭了文档发布接口,用户无法使用Word,Windows Live Writer等工具来发布博客.使用Word写 ...

  5. Spring配置bean的方法(工厂方法和Factorybean)

    通过工厂方法配置bean 通过调用静态工厂方法创建bean 通过静态工厂方法创建bean是将对象创建的过程封装到静态方法中.当客户端需要对象时,只需要简单地调用静态方法,而不关心创建对象的细节. 要声 ...

  6. swift pop实现动感按钮动画

    // //  MyButton.swift //  PopInstall // //  Created by su on 15/12/11. //  Copyright © 2015年 tian. A ...

  7. 凭借对KMP算法的了解,用java实现了一下,结果和java自带的字符串indexOf比,性能差了十倍。。。

    public class KMP { private char[] source = {'a','b','c','b','c','a','b','a','b','d','d','e','f','g', ...

  8. ES6——Class 的基本使用

    Class 语法. class 关键字声明一个类,之后以这个类来实例化对象. const Miaov=function(a,b){ this.a=a; this.b=b; return this; } ...

  9. ({i:0#.w|nt authority\iusr})Sharepoint impersonates the IUSR account and is denied access to resources

    This hotfix makes a new application setting available in ASP.NET 2.0. The new application setting is ...

  10. Dapper.Contrib.Extensions问题

    Dapper.Contrib.Extensions问题 Dapper.Extension.1.0.0.1\lib\net45\Dapper.Extension.dll Dapper.Contrib.1 ...