mono for android 第三课--页面布局(转)
对于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 第三课--页面布局(转)的更多相关文章
- Mono for Android (1) 之布局
最近和同事交接工作,首次接触mono for android, 结果画view时少了layout,页面没办法出来,各种冥思,各种找问题,最后把关于布局的一些共享出来(同事写的,哈哈): Andro ...
- Android 第三课 构建简单的用户界面
构建简单的用户界面 上一课下一课 该课程教你 创建线性布局 添加文本框 添加字符串资源 添加按钮 使输入框宽度充满整个屏幕 你也应该阅读 布局 Android的图形用户界面通过 View 和 View ...
- .Net程序猿乐Android开发---(4)注册页面布局
接下来我们介绍的登陆页面布局,在本节中,我们看一下注册页面布局,页面布局大同小异,来一起熟悉下基本控件的使用方法. 效果图: 1.加入注冊页面 右键选中layout目录,加入注冊页面.例如以下图 点击 ...
- HTML5/CSS3 第三章页面布局
页面布局 1 页面组成 2 布局相关的标签 <div></div> 定义文档中的分区或节 <span></span> 这是一个行内元素,没有任何意义 & ...
- .Net程序猿玩转Android开发---(3)登陆页面布局
这一节我们来看看登陆页面如何布局.对于刚接触到Android开发的童鞋来说.Android的布局感觉比較棘手.须要结合各种属性进行设置,接下来我们由点入面来 了解安卓中页面如何布局,登陆页面非常eas ...
- android 开发 简单的页面布局
package com.example.test; import android.app.Activity; import android.os.Bundle; import android.view ...
- mono for android 第四课--提示框(转)
其实在VS中开发安卓代码和C#还是有一些相似性,刚开始我也不知道怎么弹出提示框,于是就百度了下,再加上个人的小聪明得到一下结果 builder.setTitle表示提示框的标题. setMessage ...
- HTML后台管理页面布局
设计网页,让网页好看:网上找模板 搜 HTML模板 BootStrap 一.内容回顾: HTML 一大堆的标签:块级.行内 CSS position background text-align mar ...
- Asp.net MVC4高级编程学习笔记-视图学习第三课Razor页面布局20171010
Razor页面布局 1) 在布局模板页中使用@RenderBody标记来渲染主要内容.比如很多web页面说头部和尾部相同,中间内容部分使用@RenderBody来显示不同的页面内容. 2) 在布局 ...
随机推荐
- web应用安全权威指南(文摘)
第1章 什么是web应用的安全隐患 第3章 Web安全基础,HTTP,会话管理,同源策略 content_length 字节数 content_type mime类型 百分号编码 referer :请 ...
- git pull --rebase的使用
原文:http://www.cnblogs.com/kevingrace/p/5896706.html 使用下面的关系区别这两个操作:git pull = git fetch + git mergeg ...
- myeclispe2014启动后报错 Subclipse talks to Subversion via a Java API that requires access to native libraries.
解决方案: Window -> Preferences -> Team -> SVN, 将SVN接口的Client修改为如图所示
- swift - 动态计算文本高度
func heightOfCell(text : String) -> CGFloat { let attributes = [NSFontAttributeName:UI ...
- B-spline Curves 学习之B样条曲线的导数(8)
Derivatives of a B-spline Curve 本博客转自前人的博客的翻译版本,前几章节是原来博主的翻译内容,但是后续章节博主不在提供翻译,后续章节我在完成相关的翻译学习. (原来博客 ...
- NSIS制作安装包,如何检测并卸载已有版本
将如下代码追加到NSIS脚本的尾部即可. Var UNINSTALL_PROG Function .onInit ClearErrors ReadRegStr $UNINSTALL_PROG ...
- C#发送邮件(使用SSL,587端口)
static readonly string smtpServer = System.Configuration.ConfigurationManager.AppSettings["Smtp ...
- maven多模块启动required a bean of type com.xxx.xxx.service that could not be found.
Description: Field testService in com.xxx.xxx.api.controller.TestController required a bean of type ...
- leetcode 实现strStr()
实现strStr()函数. 给定一个 haystack 字符串和一个 needle 字符串,在 haystack 字符串中找出 needle 字符串出现的第一个位置 (从0开始).如果不存在,则返回 ...
- C语言--第0次作业;
第零次作业 1.你对网络专业或者计算机专业了解是怎样? 在高考之前,我就确定了自己的大学专业将会选择计算机方面.我认为计算机专业就业前景比较好,计算机行业发展也非常快,学科实践与创新能力也比较强,在当 ...