android.view.ViewGroup

protected void onLayout(boolean changed, int l, int t, int r, int b)

执行layout操作时调用onLayout方法。View要给它的每个Child设定size和position。拥有Children的子类需要重写onLayout方法并且调用每个Child的layout方法。

参数changed表示view的size或position发生变化。参数l, t, r, b分别表示相对于parent的left, top, right, bottom position。

 

protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)

测量View及其Content,确定measuredWidth和measuredHeight。在方法measure(int, int)中调用。重写onMeasure方法时,需要调用方法setMeasuredDimension(int, int),存储View的measuredWidth和measuredHeight。若存储失败,方法measure(int, int)会抛出异常IllegalStateException。可以调用super.onMeasure(int, int)方法。

除非MeasureSpec准许更大的size,否则measure的默认实现是background size。子类重写onMeasure(int, int)提供Content的更佳测量。如果onMeasure被重写,子类必须保证measuredWidth和measuredHeight至少是view的minHeight和minWidth。minHeight/Width通过getSuggestedMinimumHight/Width()获取。

参数width/heightMeasureSpec表示parent强加的horizontal/vertical space要求。

 

void android.view.ViewGroup.layout(int l, int t, int r, int b)

给view及其descendants设定size和position。它正是layout机制的第2个步,每个parent调用它的chlidren的layout操作。使用在measure阶段测量得到的size和position数据完成layout操作。拥有child的子类必须重写onLayout方法,调用每个child的layout操作。

 

void android.view.ViewGroup.measureChildren(int widthMeasureSpec, int heightMeasureSpec)

请View的所有children测量themseles, 测量依据是View的MeasureSpec和padding。忽略处于GONE状态的children,是否GONE状态由getChildMeasureSpec来确定。

参数width/heightMeasureSpec表示view的width/height要求。

Android API之onLayout, onMeasure的更多相关文章

  1. Android UI开发第三十三篇——Navigation Drawer For Android API 7

    Creating a Navigation Drawer中使用的Navigation Drawer的android:minSdkVersion="14",现在Android API ...

  2. android api 中文 (73)—— AdapterView

    前言 本章内容是android.widget.AdapterView,版本为Android 2.3 r1,翻译来自"cnmahj",欢迎大家访问他的博客:http://androi ...

  3. 【转】Android API 中文(14) —— ViewStub

    用一个XML源填充view.inflate(上下文对象,资源文件Id,父窗口组一般为null): 原文网址:http://www.cnblogs.com/over140/archive/2010/10 ...

  4. Android API 中文(14) —— ViewStub

    前言 关键字: android.view.ViewStub,版本为Android 2.2 r1 本章翻译来自唐明 ,这里本博负责整理和发布,欢迎其他译者一起参与Android API 的中文翻译行动, ...

  5. Android 如何在Eclipse中查看Android API源码 及 support包源码

    当我们阅读android API开发文档时候,上面的每个类,以及类的各个方法都是已经写好的方法和控件,可是我们只是在搬来使用,不知道它的原理,它是如何被实现的.android系统是开源的,所以谷歌官方 ...

  6. 搜索 录音功能 Android api

    搜索 录音功能 Android api http://www.oschina.net/android/47/ http://m.blog.csdn.net/blog/u011309801/406523 ...

  7. Android API Guides 学习笔记---Application Fundamentals(一)

    今天开始学习google官网上的API guides ,主要读了Application Fundamentals这一章节,此章节介绍了一个App的基本组成,共包括四大部分内容. 1.      App ...

  8. Instant Buy Android API Tutorial

    转自:https://developers.google.com/wallet/instant-buy/android/tutorial This tutorial guides you throug ...

  9. 【Android Api 翻译3】android api 完整翻译之Application Fundamentals (学习android必须知道的)

    Android应用程序是用Java编程语言编写的.Android SDK工具把应用程序的代码.数据和资源文件一起编译到一个Android程序包中(这个程序包是以.apk为后缀的归档文件),一个Andr ...

随机推荐

  1. mvc 从客户端 中检测到有潜在危险的 Request.Form 值

    天往MVC中加入了一个富文本编辑框,在提交信息的时候报了如下的错误:从客户端(Content="<EM ><STRONG ><U >这是测试这...&qu ...

  2. TEA加密算法java版

    这个算法简单,而且效率高,每次可以操作8个字节的数据,加密解密的KEY为16字节,即包含4个int数据的int型数组,加密轮数应为8的倍数,一般比较常用的轮数为64,32,16,推荐用64轮. 源代码 ...

  3. Tasker 中文版(4.6u2)

    http://www.anzhi.com/soft_1868913.html Tasker绝对称得上是Android系统的神器之一,与Auto Memory Manager不同,Tasker不是加速型 ...

  4. NHibernate使用无状态Sessions

    NHibernate 3.0 Cookbook第三章,Using stateless sessions的翻译. 当要处理大量的数据,你通常可能会使用更"底层"的API来改善性能,在 ...

  5. OPENGL架构

    第2章 OpenGL 简介 每台计算机都有专门处理图形的硬件,它们控制着屏幕上显示的内容.OpenGL向这种硬件发出命令,告诉它们执行什么操作.计算机游戏或者其他任意软件借助制造商提供的设备驱动程序, ...

  6. Android开发,布局xml文件命名注意事项——不能包含任何大写字母

    转自:http://blog.sina.com.cn/s/blog_628b45090100zuit.html 在开发Android应用时,会接触到布局文件,一般在 工程名/res/layout/*. ...

  7. 解决:解压zip文件却变成cpgz文件

    众所周知,zip是一种压缩文件格式,MAC OS默认支持的文件格式,当时偶尔当你打开zip文件想要解压时,却自动变成了cpgz文件而没有解压,再双击这个cpgz文件,Archive Utility又会 ...

  8. Last-Modified和If-Modified-Since

    Last-Modified 是由服务器往客户端发送的 HTTP 头 If-Modified-Since是由客户端往服务器发送的头 基础知识         1) 什么是”Last-Modified”? ...

  9. 《CUDA并行程序设计:GPU编程指南》

    <CUDA并行程序设计:GPU编程指南> 基本信息 原书名:CUDA Programming:A Developer’s Guide to Parallel Computing with ...

  10. TensorFlowIO操作(一)----线程和队列

    线程和队列 在使用TensorFlow进行异步计算时,队列是一种强大的机制. 为了感受一下队列,让我们来看一个简单的例子.我们先创建一个“先入先出”的队列(FIFOQueue),并将其内部所有元素初始 ...