【移动应用开发技术】Android学习笔记-Activity的布局_第1页
【移动应用开发技术】Android学习笔记-Activity的布局_第2页
【移动应用开发技术】Android学习笔记-Activity的布局_第3页
【移动应用开发技术】Android学习笔记-Activity的布局_第4页
【移动应用开发技术】Android学习笔记-Activity的布局_第5页
免费预览已结束,剩余1页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

【移动应用开发技术】Android学习笔记-Activity的布局

线性布局<?xml

version="1.0"

encoding="utf-8"?>

<LinearLayout

xmlns:android="/apk/res/android"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:orientation="vertical"

>

<!--

android:id

为控件指定的ID

android:text

制定控件中显示的文字,尽量使用strings.xml中定义的内容

android:grivity

指定控件的基本位置,比如居中、居右等位置

android:textSize

制定控件中字体的大小

android:background

指定该控件所只用的背景颜色,RGB命名法

android:width

控件的宽度

android:height

控件的高度

android:padding*控件的内边距,就是控件当中的内容

android:singleLine

如果设置为true则控件的内容在同一行中进行显示

android:layout_weight="1"

当前控件占的比重为1

-->

<TextView

android:id="@+id/first_string"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:layout_weight="1"

android:background="#aa0000"

android:gravity="center_vertical"

android:paddingBottom="40dip"

android:paddingLeft="10dip"

android:paddingRight="30dip"

android:paddingTop="20dip"

android:singleLine="true"

android:text="@string/hello_world"

android:textSize="15pt"

/>

<!--

上下的layout_weight都为1,每个各占1/2

-->

<TextView

android:id="@+id/second_string"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:layout_weight="1"

android:background="#00aa00"

android:gravity="center_vertical"

android:paddingBottom="40dip"

android:paddingLeft="10dip"

android:paddingRight="30dip"

android:paddingTop="20dip"

android:singleLine="true"

android:text="@string/hello_world"

android:textSize="15pt"

/>

</LinearLayout>表格布局<?xml

version="1.0"

encoding="utf-8"?>

<TableLayout

xmlns:android="/apk/res/android"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:stretchColumns="0"

>

<!--

stretchColumns使用第0列作为拉伸列

-->

<TableRow>

<TextView

android:padding="3dip"

android:background="#aa0000"

android:text="text11"

/>

<TextView

android:gravity="center_horizontal"

android:background="#00aa00"

android:padding="3dip"

android:text="text12"

/>

<TextView

android:gravity="right"

android:background="#0000aa"

android:padding="3dip"

android:text="text12"

/>

</TableRow>

<TableRow>

<TextView

android:padding="3dip"

android:background="#a00000"

android:text="text21"

/>

<TextView

android:gravity="right"

android:background="#00a000"

android:padding="3dip"

android:text="text22"

/>

</TableRow>

</TableLayout><RelativeLayout

xmlns:android="/apk/res/android"

xmlns:tools="/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:paddingBottom="@dimen/activity_vertical_margin"

android:paddingLeft="@dimen/activity_horizontal_margin"

android:paddingRight="@dimen/activity_horizontal_margin"

android:paddingTop="@dimen/activity_vertical_margin"

tools:context="com.example.layout_01.MainActivity"

>

<!--

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="@string/hello_world"

/>

-->

<!--

android:layout_above

将该控件的底部置于给定ID的控件值上

android:layout_below

将该控件的顶部置于给定ID的控件值下

android:layout_toLeftOf

将该控件的右边缘和给定ID的控件的左边缘对齐

android:layout_toRightOf

将该控件的左边缘和给定ID的控件的右边缘对齐

android:layout_alignBaseline

该控件的baseline和给定ID的空间的baseline对齐

android:layout_alignBottom

该控件的底部边缘与给定ID控件的底部边缘对齐

android:layout_alignLeft

将该控件的左边缘与给定ID控件的左边缘对齐

android:layout_alignRight

将该控件的右边缘与给定ID控件的右边缘对齐

android:layout_alignTop

将给定控件的顶部边缘与给定ID控件的顶部对齐

android:layout_alignParentBottom

如果值为true,则将该控件的底部和父控件的底部对齐

android:layout_alignParentLeft

如果值为true,则将该控件的左边缘与父控件的左边缘对齐

android:layout_alignParentRight

如果值为true,则将该控件的右边缘与父控件的与右边缘对齐

android:layout_alignParentTop

如果值为true,则将控件的顶部与父控件的顶部对齐

android:layout_centerHorizonal

如果值为true,该控件将被置于水平方向的中央

android:layout_centerInParent

如果值为true,该控件将被置于父控件水平方向和垂直方向中央

android:layout_centerVertical

如果值为true,该控件将被置于垂直方向的中央

-->

<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_dropdown_light_frame"

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_marg

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论