Android 学习第14课,Android 布局
布局分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 布局的更多相关文章
- android学习点滴一:android环境的搭建
东一点西一点,很多时间都浪费了.是该系统性的做好自己的东西了. <android学习点滴一:android环境的搭建> [环境变量]变量名:JAVA_HOME变量值:C:\Java\jdk ...
- Android学习笔记(九)——布局和控件的自定义
//此系列博文是<第一行Android代码>的学习笔记,如有错漏,欢迎指正! View是 Android中一种最基本的 UI组件,它可以在屏幕上绘制一块矩形区域,并能响应这块区域的各种事件 ...
- Android 学习第13课,android 实现发送短信的功能
1. 界面布局 界面代码: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" ...
- Android 学习第11课,android 实现拨打电话的功能
1. 先布局界面,界面采用线性垂直方式来布局 在layout 界面文件中 activity_main.xml 中 <LinearLayout xmlns:android="http:/ ...
- android学习笔记14——GridView、ImageSwitcher
GridView--网格视图.ImageSwitcher--图像切换器 ==> GridView,用于在界面上按行.列的分布形式显示多个组件:GridView和ListView父类相同——Abs ...
- Android学习手记(5) 基本UI布局
1.View和ViewGroup Activity是Android应用程序的基本管理单元,Android的每一个窗口都是通过一个Activity来定义的,但是Activity并不能直接用来显示窗口.我 ...
- Android学习笔记六:六大布局
六大界面布局方式包括: 线性布局(LinearLayout).帧布局(FrameLayout).表格布局(TableLayout).相对布局(RelativeLayout).绝对布局(Absolute ...
- Android学习笔记_3_四种布局
Android布局是应用界面开发的重要一环,在Android中,共有四种布局方式, 分别是:FrameLayout( 帧布局 ).LinearLayout (线性布局).TableLayout(表格布 ...
- Android 学习第7课,java android project 项目文档结构
src: 主要存放java源文件 gen:用于存放由开发工具自动生成的内容 R.java(很重要),用于登记各种资源的ID,编译器在你放入资源于自动生成的,程序员不需要自己去修改,是不能自己修改的 往 ...
随机推荐
- 安装VS 2013遇到的问题,及解决方案
一.在启动调试时报错 Visual Studio 2013 虽然集成安装了 IIS Express 8.0,但是并未安装 WebMatrix ,第一个问题就是这个原因造成的. 解决方案: 1.下载最新 ...
- tomcat重启脚本
#!/bin/bashPATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/binexport JAVA_HOME=/opt/jd ...
- iOS版本更新的App提交审核流程
App的版本更新估计是在所难免的了!更新App和新的App发布有何不同了?今天我们一起来看看吧!在发布App的时候我们需要通过开发者帐号——(申请)——>发布证书(需要钥匙串对证书签名也叫加密( ...
- UML 类图常用表示方法.
UML中类图实例 接口:空心圆+直线(唐老鸭类实现了‘讲人话’): 依赖:虚线+箭头(动物和空气的关系): 关联:实线+箭头(企鹅需要知道气候才迁移): 聚合:空心四边形+实线+箭头(雁群和大雁的关系 ...
- ES6模块加载
两种加载方式 加载方式 规范 命令 特点 运行时加载 CommonJS/AMD require 社区方案,提供了服务器/浏览器的模块加载方案 非语言层面的标准 只能在运行时确定模块的依赖关系及输入/输 ...
- mysql数据类型和列属性
列属性: 定义一个字段时对该字段设置的额外的信息或约束 1. 关联操作:reference 2. 字段默认值:default value 3. 主索引和唯一索引:primary key 和uni ...
- js 二维码生成 插件
<div onclick="liaotian()">点击生成二维码</div><div id="qrcode"></d ...
- 关于粒子发射(CAEmitterLayer)
技术是条长而远的路,只有不断学习丰富自己的技能才能让自己行走在路上! CAEmitterCell CAEmitterCell: CAEmitterCell是粒子发射系统里的粒子,用CAEmitterC ...
- oracle_空值判断
Oracle空值测试 比较项目 is null is not null nvl 说明 NULL true false true null true false true 'NULL' fals ...
- 初探canvas
canvas是html5新增的一个专用于图形处理的标签,利用canvas可以实现大部分图形操作canvas的一些基本操作与其他图形编程工具类似,包含:各种形状的边框.路径绘制和填充,画布属性调整,样式 ...