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

更多相关文章

  1. Android用户界面设计:框架布局
  2. [Android]继承式UI界面布局设计
  3. Android简易计算器----布局_菜单_提示框 的运用
  4. Android设置ProgressBar的前景和背景及其在多线程中的刷新
  5. Android(安卓)Viewpage禁止滑动屏幕
  6. 浅析Android中强大的Dialog
  7. Android(安卓)开发者 for Flutter (2)如何布局? XML layout 文件跑
  8. Android闹钟拓展版【安卓闹钟可换壁纸版】
  9. 使用动画和fragment改善Android表单

随机推荐

  1. android 3.0中加快启动模拟器
  2. 怎么让android定时关机
  3. Android(安卓)ListView内部组件事件响应
  4. 一定要注意 Android(安卓)内存泄漏问题
  5. Android是怎么启动的-[Android取经之路]
  6. android——shortcut
  7. android 内存消耗分析
  8. android 触摸事件、点击事件的区别
  9. android 笔记 --- 流量统计
  10. Android(安卓)FrameWork――Touch事件派