布局分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. java selenium (九) 常见web UI 元素操作 及API使用

    本篇介绍我们如何利用selenium 来操作各种页面元素 阅读目录  链接(link) <div> <p>链接 link</p> <a href=" ...

  2. silk mpu

    #include "mpu.h" #include "mbuf.h" #include "media_buffer.h" #include ...

  3. Making the Grade(POJ3666)

    题目大意: 给出长度为n的整数数列,每次可以将一个数加1或者减1,最少要多少次可以将其变成单调增或者单调减(不严格). 题解: 1.一开始我有一个猜想,就是不管怎么改变,最终的所有数都是原来的某个数. ...

  4. ssh 整合

    1. 加入 Spring 1). 加入 jar 包 2). 配置 web.xml 文件 3). 加入 Spring 的配置文件. 2. 加入 Hibernate 1). 同时建立持久化类, 和其对应的 ...

  5. WebPack 简明学习教程

    WebPack 简明学习教程 字数1291 阅读22812 评论11 喜欢35 WebPack是什么 一个打包工具 一个模块加载工具 各种资源都可以当成模块来处理 网站 http://webpack. ...

  6. mysql 查询优化

    不说话,先贴代码 public PageResult<BoTmcRaw> getLargeList(BaseCondition baseCondition) { PageResult< ...

  7. Fiddler-2 Fiddler抓包原理

    1 fiddler抓包是在 客户端和服务器之间建立一个代理服务器,监听本机发出的请求和服务器返回的响应结果. 截一张官网的图: 2 启动fiddler之前,[dinghanhua]先来看一下代理服务器 ...

  8. 将本地代码上传至github备份的操作方法

    这篇文章写得是windows下的使用方法. 第一步:创建Github新账户 第二步:新建仓库 第三步:填写名称,简介(可选),勾选Initialize this repository with a R ...

  9. 19:A*B问题

    总时间限制:  1000ms 内存限制:  65536kB 描述 输入两个正整数A和B,求A*B. 输入 一行,包含两个正整数A和B,中间用单个空格隔开.1 <= A,B <= 50000 ...

  10. Hibernate 学习笔记一

    Hibernate 学习笔记一 今天学习了hibernate的一点入门知识,主要是配置domain对象和表的关系映射,hibernate的一些常用的配置,以及对应的一个向数据库插入数据的小例子.期间碰 ...