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 ...
随机推荐
- win7下 安装 Flask
参考: http://my.oschina.net/935572630/blog/375758 一 环境版本: os: win7 x64 python: 2.7.10 x64 二 安装步骤: 由于fl ...
- 四则运算GUI设计2.0
使用QT设计的界面如下: 程序流程是点击开始出题,会在题目后面的框中显示所出的题目,在输入答案以后点击提交答案会判断输入的答案是否正确. 输入后的界面: 部分代码如下: qtyunsuan.h文件: ...
- cocos2dx day 2 - Sprites
1.Sprite 对sprite设置anchor point,对应的位置 // DEFAULT anchor point for all Sprites mySprite->setAnchorP ...
- 用svg制作loading动画
首先说明:由于各浏览器对svg动画事件支持不统一,此loading动画在Firefox,Opera,Chrome中均没有问题,IE和Safari中有问题,可能是不支持SIML写动画的语法, 但是用Ca ...
- VC++6.0 配置CppUTest测试环境
最近看<软件项目成功之道>,书中无数次提及到“单元测试”对于项目成败的重要性,看到同事将CppUTest用于Linux动态库测试,于是在VC++6.0环境下搭建一个基于CppUTest的单 ...
- 关于一次oracle sqlplus可登陆,但监听起不来的解决。由于listener.log文件超过4G
1.在oracle服务器上cmd 执行 lsnrctl 执行start 过了好久,提示监听程序已经启动. 再执行status 过来好久,才提示命令执行成功. 最后找到原因是因为C:\Oracle\di ...
- MVVM模式下弹出窗体
原地址:http://www.cnblogs.com/yk250/p/5773425.html 在mvvm模式下弹出窗体,有使用接口模式传入参数new一个对象的,还有的是继承于一个window,然后在 ...
- ORACLE插入DATE类型字段
1 怎样在ORACLE中输入DATE类型的字段 insert into table_name (date_column) values(to_date('2006-06-04','yyyy-mm-dd ...
- java.lang.OutOfMemoryError: Java heap space解决办法
进入到tomcat/bin目录下,编辑catalina.bat,在这个文件最前面加入一句:set JAVA_OPTS=-Xms384m -Xmx384m 保存退出,重启tomcat服务即可. 该异常应 ...
- IOS 本地通知推送消息
在现在的移动设备中,好多应用性的APP都用到了推送服务,但是有好多推送的内容,比如有的只是单纯的进行推送一个闹钟类型的,起了提醒作 用,有的则是推送的实质性的内容,这就分为推送的内容来区别用什么推送, ...