Android_layout 布局(二)
昨天学习了layout 布局的线性布局和相对布局。
今天我们学习剩余的三个布局,分别是:
一、帧布局(FrameLayout)
在这个布局中,所有的子元素都不能被指定放置的位置,它们通通放于这块区域的左上角,并且后面的子元素直接覆盖在前面的子元素之上,将前面的子元素部分和全部遮挡。
注:帧布局和线性布局的区别
在大体上的用法等等两者还是很相似的。但是有一点两点的根本区别。
帧布局是有“深度”的,它只追求在这个点上去深入。
线性布局是有“广度”的,它是向外延展的,他就是一个“面”。

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" > <TextView
android:id="@+id/textView1"
android:layout_width="300dp"
android:layout_height="300dp"
android:text="1"
android:background="#ff00ff"/> <TextView
android:id="@+id/textView2"
android:layout_width="200dp"
android:layout_height="200dp"
android:text="2"
android:background="#00ffff" /> <TextView
android:id="@+id/textView3"
android:layout_width="100dp"
android:layout_height="100dp"
android:background="#ff0000"
android:text="3" /> </FrameLayout>

二、绝对布局(AbsoluteLayout)
1.absoluteLayout 又叫坐标布局,可以直接指定子元素的绝对位置(x,y)
2.由于手机屏幕尺寸差别比较大,使用绝对定位的适应性会比较差,在屏幕的适配上有缺陷
3.子控件的属性
android:layout_x="35dip" 控制当前子类控件的x位置
android:layout_y="35dip" 控制当前子类控件的y位置
注:建议最好不要使用绝对布局,我们手机屏幕大小不同,你用这个型号,这个大小的手机定位好的位置,当你换了个手机尺寸不一样的,就会将你的布局打乱,这样很不好。我在这就不演示了。记住,记住,最好不要使用,不利用开发。
三、表格布局(TableLayout)
表格布局类似于我们html 中的table 元素一样。
我们来看看他的属性。


接下来我们做个简单的表格布局的栗子来认识下这个表格布局。计算器
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns="*" >
<EditText
android:layout_width="match_parent"
android:layout_height="60dp"
android:gravity="center_vertical|right"
android:layout_weight="1"/>
<TableRow
android:layout_weight="1"> <Button
android:id="@+id/btn7"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="7" /> <Button
android:id="@+id/btn8"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="8" /> <Button
android:id="@+id/btn9"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="9" /> <Button
android:id="@+id/btnchu"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="/" />
</TableRow> <TableRow
android:layout_weight="1"> <Button
android:id="@+id/btn4"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="4" /> <Button
android:id="@+id/btn5"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="5" /> <Button
android:id="@+id/btn6"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="6" /> <Button
android:id="@+id/btncheng"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="*" />
</TableRow> <TableRow
android:layout_weight="1"> <Button
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="1" /> <Button
android:id="@+id/btn2"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="2" /> <Button
android:id="@+id/btn3"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="3" /> <Button
android:id="@+id/btnjian"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="-" />
</TableRow> <TableRow
android:layout_weight="1"> <Button
android:id="@+id/btn0"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="0" /> <Button
android:id="@+id/btndian"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="." /> <Button
android:id="@+id/btnjia"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="+" /> <Button
android:id="@+id/btndeng"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="=" />
</TableRow> <TableRow
android:layout_weight="1"> <Button
android:id="@+id/clear"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_span="4"
android:text="clear" />
</TableRow> </TableLayout>
效果显示是这样的。

关于android 的 layout 布局,就暂时讲这些,关于这几大布局的属性,大家有空都可以去试试,多练习下布局的排布,综合起来,排布一个页面什么的。属性每个布局中的属性。
今天就先到这,欢迎大家一起学习。
Android_layout 布局(二)的更多相关文章
- 基本CSS布局二
基本CSS布局二------基本页面布局二 /*主面板样式*/ #container { width:100%; margin:0px auto;/*主面板DIV居中*/ } /*顶部面板样式*/ # ...
- Android_layout 布局(一)
今天主要学习了Android 的layout布局. Android layout 布局一般分为五种: LinearLayout (线性布局) :子组件按照垂直或者水平方向来布局. RelativeLa ...
- CSS布局(二) 盒子模型属性
盒子模型的属性 宽高width/height 在CSS中,可以对任何块级元素设置显式高度. 如果指定高度大于显示内容所需高度,多余的高度会产生一个视觉效果,就好像有额外的内边距一样: 如果指定高度小于 ...
- Android的学习第六章(布局二--RelativeLayout)
今天我们来说一下Android布局中的Relativelayout布局(相对布局) 根据英译过来意思是相对布局,很容易理解,这一样布局使用的是元素与元素之间的微调做到布局的 含义:通过元素与元素之间的 ...
- Android开发--布局二
1.Andrid:控件布局(表格布局)TableLayout 有多少个TableRow对象就有多少行, 列数等于最多子控件的TableRow的列数 直接在TableLayout加控件,控件会占据一行 ...
- android菜鸟学习笔记7----android布局(二)
3.FrameLayout:帧布局 如同Flash或者photoshop中图层的概念,在上面的图层遮盖下面的图层,没被遮到的地方仍然显示出来. 右击res/layout,然后在弹出的菜单中选择new, ...
- 从汇编看c++中的虚拟继承及内存布局(二)
下面是c++源码: class Top {//虚基类 public: int i; Top(int ii) { i = ii; } virtual int getTop() { cout <&l ...
- 【ExtJS】FormPanel 布局(二)
周末2天好好学习了下布局,现在都给实现了吧. 5.border布局: Border布局将容器分为五个区域:north.south.east.west和center.除了center区域外,其他区域都需 ...
- 【ALearning】第四章 Android Layout组件布局(二)
前面我们分别介绍和学习了LinearLayout(线性布局).FrameLayout(单帧布局)和AbsoluteLayout(绝对布局).这次我们要进行RelativeLayout(相对布局)和Ta ...
随机推荐
- 【菜鸟学习jquery源码】数据缓存与data()
前言 最近比较烦,深圳的工作还没着落,论文不想弄,烦.....今天看了下jquery的数据缓存的代码,参考着Aaron的源码分析,自己有点理解了,和大家分享下.以后也打算把自己的jquery的学习心得 ...
- tomcat 9.0配置管理员用户名和密码
登录后,可以管理查看发布网站的信息,岗安装好的tomcat是没有管理密码的,可以在配置文件中修改. 在conf/tomcat-users.xml的文件中修改配置,默认的角色用户是被注销掉的.我去掉注释 ...
- CentOS 7安装Sublime text3
最近使用centos7,发现桌面有了大的改善,完全能够使用桌面进行开发.现在进行sublime text3的安装. 官网下载只有windows,ios,ubuntu这几个类型,我们选择ubuntu64 ...
- Frameset的使用
一.frameset 1. 属性 ①border 设置框架的边框粗细. ②bordercolor 设置框架的边框颜色. ③frameborder 设置是否显示框架边框.设定值只有0.1:0 表示不要边 ...
- 【转】bind - DNS 設定
http://www.l-penguin.idv.tw/article/dns.htm 參考資訊 DNS 是所有伺服之母,電腦連節時均以 IP 為主,比方說輸入 202.43.195.52 就會到台灣 ...
- Aop资料整理
1.Spring AOP 实现机制2 http://cjhz.iteye.com/blog/2245161 http://itindex.net/detail/29812-aop 2.跟我学aspec ...
- html基础 样式
html样式:本文演示如何在head中添加样式信息使文本格式化 <html> <head> <style type="Text/css"> h1 ...
- PlayerPrefs游戏存档
本地存储.相当于Flash里面的SharedObject. Android位置:机器自身存储的(非扩展卡)/data/data/appname/shared_prefs/{AppName}.xml,如 ...
- 北京易信软科信息技术有限公司-仓库管理系统V1.0
北京易信软科您可信赖的北京软件研发服务商,公司团队有多年应用软件设计制作及开发经验,为各大企业提供软件设计.制作及维护服务,为用户提供可靠高效的应用服务平台 我们通过专业的项目实施流程,为您提供优质的 ...
- ACM知识点
基础算法 高精 模拟 分治 贪心 排序 DFS 迭代加深搜索 BFS 双向BFS 动态规划 DAG上DP 树上DP 线性DP 图算法 最短路 FLYD DJATL BF 最大流 Dinic ISAP ...