布局分4种:

1. LinearLayout (线性布局)

file:///H:/tool/01/Android/android-sdk-windows/docs/guide/topics/ui/layout/linear.html

事例代码:

2. RelativeLayout (相对布局)

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
> <TextView
android:id="@+id/numbeLabel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/number" /> <EditText
android:id="@+id/number2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="@null"
android:layout_below="@id/numbeLabel" //这里表示这个控件显示在id为numberLabel这个控件下面
/> <Button
android:id="@+id/ok"
android:text="@string/ok"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/number2"
android:layout_alignParentRight="true" //这里表示这个控件在父对象里面是居右显示
android:layout_marginLeft="10px" //这里表示这个控件跟左边这个控制的间距是10像素
/> <Button
android:text="@string/cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/ok" //表示显示在ok这个按钮左边
android:layout_alignTop="@id/ok" //表示与ok这个按钮,顶对齐
/> </RelativeLayout>

3. TableLayout (表格布局)

4. FrameLayout (帧布局)

就像gif图片一样,或者可以理解成层,可以叠加在一起

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" > <ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/bofangtwo"
android:contentDescription="@string/app_name"
/> <ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/bofang"
android:contentDescription="@string/app_name"
android:layout_gravity="center"
/>
</FrameLayout>

注意:在写

android:src="@drawable/bofang"的时候,注意图片后面的扩展名不要带,带上就会出错!
把bofang.png和bofangtwo.jpg复制到res中的drawable-hdpi中

Android 学习第14课,Android 布局的更多相关文章

  1. android学习点滴一:android环境的搭建

    东一点西一点,很多时间都浪费了.是该系统性的做好自己的东西了. <android学习点滴一:android环境的搭建> [环境变量]变量名:JAVA_HOME变量值:C:\Java\jdk ...

  2. Android学习笔记(九)——布局和控件的自定义

    //此系列博文是<第一行Android代码>的学习笔记,如有错漏,欢迎指正! View是 Android中一种最基本的 UI组件,它可以在屏幕上绘制一块矩形区域,并能响应这块区域的各种事件 ...

  3. Android 学习第13课,android 实现发送短信的功能

    1. 界面布局 界面代码: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" ...

  4. Android 学习第11课,android 实现拨打电话的功能

    1. 先布局界面,界面采用线性垂直方式来布局 在layout 界面文件中 activity_main.xml 中 <LinearLayout xmlns:android="http:/ ...

  5. android学习笔记14——GridView、ImageSwitcher

    GridView--网格视图.ImageSwitcher--图像切换器 ==> GridView,用于在界面上按行.列的分布形式显示多个组件:GridView和ListView父类相同——Abs ...

  6. Android学习手记(5) 基本UI布局

    1.View和ViewGroup Activity是Android应用程序的基本管理单元,Android的每一个窗口都是通过一个Activity来定义的,但是Activity并不能直接用来显示窗口.我 ...

  7. Android学习笔记六:六大布局

    六大界面布局方式包括: 线性布局(LinearLayout).帧布局(FrameLayout).表格布局(TableLayout).相对布局(RelativeLayout).绝对布局(Absolute ...

  8. Android学习笔记_3_四种布局

    Android布局是应用界面开发的重要一环,在Android中,共有四种布局方式, 分别是:FrameLayout( 帧布局 ).LinearLayout (线性布局).TableLayout(表格布 ...

  9. Android 学习第7课,java android project 项目文档结构

    src: 主要存放java源文件 gen:用于存放由开发工具自动生成的内容 R.java(很重要),用于登记各种资源的ID,编译器在你放入资源于自动生成的,程序员不需要自己去修改,是不能自己修改的 往 ...

随机推荐

  1. js判断qq浏览器

    if(navigator.userAgent.toLowerCase().toString().indexOf('qqbrowser') > -1){ console.log('qq');}el ...

  2. Pycharm快捷方式

    PYCHARM的快捷方式 PyCharm3.0默认快捷键(翻译的)1.编辑(Editing)Ctrl + Space 基本的代码完成(类.方法.属性)Ctrl + Alt + Space 快速导入任意 ...

  3. git branch(git 的branch 使用方法)

    查看分支:         $ git branch    该命令会类出当先项目中的所有分支信息,其中以*开头的表示当前所在的分支.参数-r列出远程仓库中的分支,而-a则远程与本地仓库的全部分支. 创 ...

  4. iOS检测版本更新

    有时候为了需求,我们需要检测app版本更新今天在这里整合下 //获取当前版本号 NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDi ...

  5. css3选择器详解

    css中除了早先最早的,ID选择器,class选择器一些以外在css3中新加入了新的选择器,新选择器的使用大大的方便了我们的编程,下面我就说一些css3的选择器的使用方法, p       选择了所有 ...

  6. stm8s103头文件

    //============================================================================== //================= ...

  7. 用Mockito mock普通的方法

    上面的例子是很理想化的状态,但是在实际的开发中,我们需要经常调用一些依赖特定环境的函数或者调用同事写的代码,而同事仅提供了接口.这个时候就需要利用Mockito来协助我们完成测试. 当然,你可以选择e ...

  8. 更新App版本的流程

    上班一年了还没有自己打包上传过APP,周五下班时项目经理手把手教了我一遍,我大致把流程在这里回顾一下: 1.首先要将svn上的代码拷贝一份到分支上,用终端操作:svn cp https://192.1 ...

  9. Vsftp精解之安装配置及原理(一)

    简介 Vsftp(Very Secure FTP)是一个基于GPL发布的类Unix系统上使用的FTP服务器软件,是一款小巧而又易用FTP服务器程序,Vsftpd 在安全性.高性能及稳定性三个方面有很好 ...

  10. Win7 下IIS(7.5)发布 ASP.NET MVC

    操作系统 Win 7 旗舰版 开发工具 VS2015 使用技术 IIS7.5 + MVC4.0 一 . 在IIS上部署程序后出现错误-当前标识(NT AUTHORITY/NETWORK SERVICE ...