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要求。

更多相关文章

  1. Android平台向web应用get、post方式提交信息案例
  2. 【Android(安卓)Developers Training】 24. 保存键值对
  3. DialogFragment 报错汇总
  4. Android(安卓)ART Hook & 注入实现细节
  5. Android(安卓)UI开发详解之ActionBar
  6. android四种点击事件触发写法
  7. Android-NDK开发之基础--Android(安卓)JNI实例代码(一)-- 在JNI
  8. 修改Android模拟器的system分区,以及加入SuperSU
  9. 浅谈android IOC控制反转二(事件篇)

随机推荐

  1. Android图片压缩——Luban鲁班压缩
  2. android dpi dp 和px之间的关系
  3. android 使用SharedPreferences保存list
  4. android的sd卡上创建目录不显示
  5. Android(安卓)积累一些RxJava2.0有关的知
  6. android常见问题记录(03.13update)
  7. android 控件
  8. 给Android(安卓)JellyBean添加internal r
  9. 使用 adb 命令向 Android(安卓)发送广播
  10. 如何实现Siri中的波纹动画