最近学习android自定义viewgroup,花了很多时间来处理,真的真的非常难找,特此记录
setMeasuredDimension((widthMode == MeasureSpec.EXACTLY ? sizeWidth : width), (heightMode == MeasureSpec.EXACTLY ? sizeHeight : height));
上面的代码能正常显示
setMeasuredDimension((widthMode == MeasureSpec.AT_MOST ? width : sizeWidth), (heightMode == MeasureSpec.EXACTLY ? height : sizeHeight));
上面的代码显示异常,自定义viewGroup不显示
字段说明
字段 | 说明 |
---|---|
sizeWidth | measureSpec中的宽度 |
width | 自己测量的宽度 |
sizeHeight | measureSpec中的高度 |
height | 自己测量的高度 |
暂时还没弄懂时为什么,后续记录