View类的onMeasure(int widthMeasureSpec,int heightMeasureSpec)方法中的参数值单位是多少?

时间:2011-09-06 11:25:16

标签: android view

可以任何身体让我知道参数的单位是什么  onMeasure(int widthMeasureSpec,int heightMeasureSpec)此View类方法。

我打印日志分别返回1073742144,-2147483251。

1 个答案:

答案 0 :(得分:9)

该值是模式和大小的组合。使用View.MeasureSpec.getMode(widthMeasureSpec)获取模式(MeasureSpec.EXACTLYMeasureSpec.AT_MOSTMeasureSpec.UNSPECIFIED之一;您可能想知道的是View.MeasureSpec.getSize(widthMeasureSpec),大小(以像素为单位)。

另请参阅source code of MeasureSpec