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,编译器在你放入资源于自动生成的,程序员不需要自己去修改,是不能自己修改的 往 ...
随机推荐
- win7/8/10安装过程中将动态磁盘转为basic
在分区界面运行Shift+F10 在命令窗口运行Diskpart list diskpart select disk n(n为磁盘号) clean convert xxx PS:xxx代表要转换的结果 ...
- C++ 读取txt文本内容,并将结果保存到新文本
循序渐进学习读文件 // readFile.cpp : 定义控制台应用程序的入口点. #include "stdafx.h" #include <iostream> # ...
- 高性能Web服务器Nginx的配置与部署研究系列(1)-- 入门 hello work
简介: Nginx 是一个基于 BSD-like 协议.开源.高性能.轻量级的HTTP服务器.反向代理服务器以及电子邮件(SMTP.POP3.IMAP)服务器.Nginx 是由一个俄罗斯的名叫“Igo ...
- CALayer 3 详解 -----转自李明杰
CALayer3-层的属性 本文目录 一.隐式动画属性 二.position和anchorPoint 回到顶部 一.隐式动画属性 * 在前面几讲中已经提到,每一个UIView内部都默认关联着一个C ...
- stm8s103串口
#include "uart.h" #define UART2#define uart_115200 1 void Init_UART2(void){#ifdef UART2 ...
- 写程序该选Mac 还是PC ?(转)
原文链接:http://gogojimmy.net/2012/04/07/why-programmer-should-use-mac/ 序 一个竞争的市场,就会有对立的产生,这世界存在着很多不同的领域 ...
- C语言经典例题100
C语言经典例题100 来源 http://www.fishc.com 适合初学者 ----------------------------------------------------------- ...
- 最强密码 (百度之星复赛 T5)
题目大意: 给出一个字符串A,要求最短的字符串B,B不是A的子序列. 求最短长度 和 最短的字符串个数 |A|<=105. 题解: 1.比赛的时候没有想出来,时隔一个多月又看到了这道题,虽 ...
- 简单研究Loader笔记
2015-11-11 18:25:34 1. Loader是什么? /** * Static library support version of the framework's {@link and ...
- 【PHP】分页条函数封装
这两天在学习PHP 想做一个前端后台都包含的网站 看了一些视频发现大牛们都是将封装起来实现代码的重用性 本人技拙也写了个分页条函数的封装 分页条在用PHP网站开发中十分常用 通过封装代码来提高网站开发 ...