标签:疑问 most 变量 size idt 包括 track mos 容器
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); }
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // super.onMeasure(widthMeasureSpec, heightMeasureSpec); // 宽和高的计算模式 int modeWidth = MeasureSpec.getMode(widthMeasureSpec); int modeHeight = MeasureSpec.getMode(heightMeasureSpec);
//真正的宽和高的数值 int sizeWidth = MeasureSpec.getSize(widthMeasureSpec); int sizeHeigth = MeasureSpec.getSize(heightMeasureSpec); measureChildren(widthMeasureSpec, heightMeasureSpec); setMeasuredDimension(sizeWidth, sizeHeigth); }
ViewGroup.LayoutParams.MATCH_PARENT
ViewGroup.LayoutParams.WRAP_CONTENT
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // 宽和高的计算模式 int modeWidth = MeasureSpec.getMode(widthMeasureSpec); int modeHeight = MeasureSpec.getMode(heightMeasureSpec); //拿到父容器推荐的宽和高 int sizeWidth = MeasureSpec.getSize(widthMeasureSpec); int sizeHeigth = MeasureSpec.getSize(heightMeasureSpec);
<span style="white-space:pre"> </span>//这里測量每个孩子的宽和高 if (modeWidth == MeasureSpec.ATMOST) //sizeWidth = 计算的值 } if (modeHeight == MeasureSpec.ATMOST<span style="font-family: Arial, Helvetica, sans-serif;">)</span> //sizeHeigth = 计算的值 } setMeasuredDimension(sizeWidth, sizeHeigth); }
标签:疑问 most 变量 size idt 包括 track mos 容器
原文地址:http://www.cnblogs.com/yutingliuyl/p/7002972.html