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,编译器在你放入资源于自动生成的,程序员不需要自己去修改,是不能自己修改的 往 ...
随机推荐
- 国内技术管理人员批阅google的“春运交通图”项目(大公司下的高效率)<转载>
在整理一份报告的时候,偶然看到2008年春节期间google推出的“春运交通图”项目建设历程报道,很受启发,随以国内的技术管理人员眼光批阅了这篇文章,同时也是自嘲吧. 以下黑色字体是原报道,红色字体是 ...
- ReportingService报表入门
今天我们来学习一下ReportingService报表的制作. ReportingService是微软提供的一个制作报表的工具,它集成在Microsoft Visual Studio中. 启动Visu ...
- -bash: msgunfmt: command not found
执行命令:msgunfmt frontend.mo -o frontend.po 解决方法: 安装gettext完成后如下:
- Pycharm快捷键
相比于eclipse,pycharm的确很方便,现就一些常用的快捷键记录一下: CTRL Q: 在参数列表位置,显示可以输入的所有参数.CTRL Q: 查看选中方法的文档字符串 阅读CTRL -: 折 ...
- MFC-01-Chapter01:Hello,MFC---1.3 第一个MFC程序(01)
#include <afxwin.h> class CMyApp : public CWinApp { public: virtual BOOL InitInstance(); }; cl ...
- JAVA 中文转GBK内码方法
不能谷歌,百度了很久,没有直接的转换方法,参考 byte[]数组与十六进制字符串与字符串的互相转换 http://blog.163.com/roadwalker@126/blog/static/113 ...
- 使用开源DocX 生成Word
工作中遇到这样一个需求,要求把选中的订单导出到一张Word中(要求不能使用Com组件) 要求实现图如下 下面是代码实现 先引用 DocX string tempName = Guid.NewGuid ...
- 简单的ATM,见笑见笑
#include<stdio.h>#include<string.h> void main(){ char a[4]={0}; char e[]="9527&quo ...
- SQL Server 内置函数、临时对象、流程控制
SQL Server 内置函数 日期时间函数 --返回当前系统日期时间 select getdate() as [datetime],sysdatetime() as [datetime2] getd ...
- layoutSubviews 与 drawRect
layoutSubviews总结 ios layout机制相关方法 - (CGSize)sizeThatFits:(CGSize)size- (void)sizeToFit——————- - (voi ...