Android layout、onLayout 一些简要说明(转)
2015-11-05 13:41
471 查看
View中:
public void layout(int l,int t,int r,int b) {
...
onLayout
...
}
//changed 表示是否有新的位置或尺寸
protected void onLayout(boolean changed,int left,int top,int right,int bottom) {
//空实现
}
ViewGroup中:
public final void layout(int l,int t,int r,int b) {
...
super.layout(l, t, r, b);
...
}
//changed 表示是否有新的位置或尺寸
protected abstract void onLayout(boolean changed, int l,int t, int r,int b);
说明:
1. 自定义一个view时,建议重写onLayout,以设定它的位置。
在外部调用时,调用layout(),触发设定位置。
2. 自定义一个viewGroup时,必须且只能重写onLayout。
需要在设定子view的位置:调用subview.layout(); 触发
http://blog.csdn.net/jjwwmlp456/article/details/43983265
public void layout(int l,int t,int r,int b) {
...
onLayout
...
}
//changed 表示是否有新的位置或尺寸
protected void onLayout(boolean changed,int left,int top,int right,int bottom) {
//空实现
}
ViewGroup中:
public final void layout(int l,int t,int r,int b) {
...
super.layout(l, t, r, b);
...
}
//changed 表示是否有新的位置或尺寸
protected abstract void onLayout(boolean changed, int l,int t, int r,int b);
说明:
1. 自定义一个view时,建议重写onLayout,以设定它的位置。
在外部调用时,调用layout(),触发设定位置。
2. 自定义一个viewGroup时,必须且只能重写onLayout。
需要在设定子view的位置:调用subview.layout(); 触发
http://blog.csdn.net/jjwwmlp456/article/details/43983265
相关文章推荐
- Android draw、onDraw、dispatchDraw、invalidate、computeScroll 一些简要说明(转)
- Android SDK和ADT版本问题
- android学习指南
- android 学习路线指南
- Cordova or Xamarin 用.net开发IOS和Android程序
- Android EventBus源码解析 带你深入理解EventBus
- 学习Android有用的插件和工具推荐
- Android-04 setCompoundDrawables与setCompoundDrawablesWithIntrinsicBounds的区别
- android content provider java.lang.SecurityException: Permission Denial异常解决
- android底层开发进阶(2)--makefile笔记与android的平台编译
- android intent 选择文件
- AsyncTask的使用
- 仿QQ聊天(1)—无形装比,最为致命
- Android开发入门------开发环境的搭建
- Android基本控件ListView的使用总结
- Android--简单开发和使用ContentProvider数据共享
- Activity启动过程详解
- 强烈推荐android studio用的几个插件
- Android开发&常用权限使用
- 如何在VirtualBox虚拟机中安装Android x86