关于ViewGroup

来源:互联网 发布:商超网络信息平台 编辑:程序博客网 时间:2024/06/05 13:33

1.  onMeasure onLayout 在每次Child View发生变化时都会被调用 , dispatchDraw 在 invalidate时调用

2.  手动测Child View的大小  没有LayoutParams 指定一个默认的  getChildMeasureSpec第一个参数为spec , 这里是简写


LayoutParams params=view.getLayoutParams();if (null==params)    params=new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);int widthSpec=ViewGroup.getChildMeasureSpec(View.MeasureSpec.UNSPECIFIED, 0, params.width);int heightSpec=ViewGroup.getChildMeasureSpec(View.MeasureSpec.UNSPECIFIED,0,params.height);view.measure(widthSpec,heightSpec);3.invalidate 不刷新界面 使用postInvalidate

0 0