我做了一个自定义视图.如果将视图添加到布局XML文件并将高度设置为fill_parent“ specSize”,则返回0.为什么?
码:
@Override
protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec) {
int measuredHeight = 90;
int specMode = MeasureSpec.getMode(heightMeasureSpec);
int specSize = MeasureSpec.getSize(MeasureSpec.getMode(heightMeasureSpec));
if(specMode != MeasureSpec.UNSPECIFIED){
measuredHeight = specSize;
}
setMeasuredDimension(60,measuredHeight);
}
有人知道我如何获得fill_parent的高度吗?
最佳答案