android 相对布局
来源:互联网 发布:linux内核熵池 编辑:程序博客网 时间:2024/05/01 02:41
今天学习了RelativeLayout,线性布局不是一直能满足我们的要求,RelativeLayout允许子元素指定她们相对与其他元素或父元素的位置(通过id指定)。实例如下
-------------main.xml----------------
使用了RelativeLayout定义了布局方式
<?xml version="1.0" encoding="utf-8"?><!-- android:background 定义了控件的背景色 android:layout_*:可以用来控制控件的位置 android:layout_above:位于指定控件的上面 android:layout_blow:位于指定控件的下面 android:layout_toLeftOf:位于指定控件的左面 android:layout_toRightOf:位于指定控件的右面 android:layout_alignBottom:本控件的下边缘和指定控件下边缘对齐 android:layout_alignTop:本控件的上边缘和指定控件的上边缘对齐 android:layout_alignLeft:本控件的左边缘和指定控件的左边缘对齐 android:layout_alignRight:本控件的右边缘和指定控件的右边缘对齐 android:layout_alignParentButtom:如果值为true则指定控件和父控件的下边缘对齐 android:layout_alignParentTop:如果值为true则指定控件和父控件的上边缘对齐 android:layout_alignParentRight:如果值为true则指定控件和父控件的右边缘对齐 android:layout_alignParentLeft:如果值为true则指定控件和父控件的左边缘对齐 android:layout_centerHorizontal:如果值为true则指定控件再起父控件中水平居中 android:layout_centerVertical:如果值为true则指定控件再起父控件中垂直居中 android:layout_centerInParent:如果值为true则指定控件再起父控件中完全居中 --><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:id="@+id/label" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Type here:"/> <EditText android:id="@+id/entry" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@android:drawable/editbox_background" android:layout_below="@id/label"/> <Button android:id="@+id/ok" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/entry" android:layout_alignParentRight="true" android:layout_marginLeft="10dip" android:text="确定" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toLeftOf="@id/ok" android:layout_alignTop="@id/ok" android:text="取消" /></RelativeLayout>
-------RelativeLayoutActivity---------import android.app.Activity;import android.os.Bundle;public class RelativeLayoutActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); }}
- Android 布局:相对布局
- android相对布局 相对对齐
- android之相对布局
- android 相对布局
- Android 相对布局
- Android中的相对布局
- android之相对布局
- android 相对布局心得
- android 相对布局
- android 相对布局属性
- android相对布局
- Android相对布局
- android 相对布局属性
- Android 相对布局
- Android中的相对布局
- android 相对布局小结
- android 相对布局
- Android相对布局
- How to create a Maven web app and deploy to Tomcat - fast
- usb otg的一些简介
- POJ 2263 Heavy Cargo(Dijkstra算法)
- iphone
- 字符编码
- android 相对布局
- NSString的使用
- ASP.NET 企业架构
- malloc()与 calloc()区别 (转)
- 串的模式匹配 经典KMP算法
- 用GDB调试程序(一)
- vb 6.0编程错误
- ZOJ 3229 Shoot the Bullet 有源汇上下界最大流
- 2011-9-17 17:22:00