自定义控件-继承ViewGrroup
来源:互联网 发布:opta数据中文 编辑:程序博客网 时间:2024/06/06 20:22
#自定义控件——继承ViewGroup
##常用方法总结
###1.两个参数的初始化构造函数,解析自定义控件的xml时调用创建对象
###2. onFinishInflate()
自定义控件的xml解析完调用,此时子控件都已添加完毕,可以在这个方法里用getChildCount()
和getChildAt(int index)得到子控件,并设置事件监听
###3.onMeasure(int widthMeasureSpec, int heightMeasureSpec)
测量自己和子控件的宽高
调用如下两个方法
measureChildren(widthMeasureSpec, heightMeasureSpec);
改写super.onMeasure()方法中调用的getDefaultSize方法,根据xml文件中的设置得到控件的宽高
setMeasuredDimension(measuredWidth, measuredHeight);
###4.onLayout(boolean changed, int l, int t, int r, int b)
layout(l, t, r, b );对子控件进行布局
##常用方法总结
###1.两个参数的初始化构造函数,解析自定义控件的xml时调用创建对象
###2. onFinishInflate()
自定义控件的xml解析完调用,此时子控件都已添加完毕,可以在这个方法里用getChildCount()
和getChildAt(int index)得到子控件,并设置事件监听
###3.onMeasure(int widthMeasureSpec, int heightMeasureSpec)
测量自己和子控件的宽高
调用如下两个方法
measureChildren(widthMeasureSpec, heightMeasureSpec);
改写super.onMeasure()方法中调用的getDefaultSize方法,根据xml文件中的设置得到控件的宽高
setMeasuredDimension(measuredWidth, measuredHeight);
###4.onLayout(boolean changed, int l, int t, int r, int b)
layout(l, t, r, b );对子控件进行布局
0 0
- 自定义控件-继承ViewGrroup
- 继承View自定义控件
- 自定义控件-继承View
- Android 自定义控件,继承控件,组合控件
- WPF 继承自定义的控件
- Extjs 通过继承自定义控件
- WPF 继承自定义的控件
- Android自定义控件---继承Linearlayout
- 自定义控件之 继承 View
- android 自定义控件继承TextView
- 继承View自定义开关控件
- 自定义view之继承控件
- 自定义控件继承View------Music
- Android自定义控件(三)继承控件
- 自定义控件之继承原控件
- Android自定义控件-继承已有控件
- C#继承基本控件实现自定义控件
- 如果继承自定义控件里的event
- hiho #1082 : 然而沼跃鱼早就看穿了一切
- BZOJ 2761 不重复数字(水题)
- 001——jdk环境配置
- Longest Consecutive Sequence
- iOS提示框之 MBProgressHUD 与 SVProgressHUD
- 自定义控件-继承ViewGrroup
- poj 3494 Largest Submatrix of All 1’s 单调栈/DP迭代法
- # android studio使用遇到的问题
- 谈谈Js闭包的那些事儿
- java面试宝典学习笔记(三)
- 自定义控件—Scroller屏幕平缓滑动工具类
- springMvc工作流程图
- 四种常用的排序算法(冒泡、选择、倒序、插入)
- 使用achartengine 画图(折线、柱状、范围图、以及饼图)’