各位前辈, 最近试onMeasure量测的值
有一个问题想请教各位前辈
我做了一个MyView, 然后LayoutParams设定为(WRAP_CONTENT,WRAP_CONTENT)
把它装在一个rl的RelativeLayout里面, rl设定为(100, 150)
然后我观察onMeasure的结果, 结果如下
12-05 01:48:14.678: I/HelloMeasure_measureWidth(537): specSize = 100
12-05 01:48:14.678: I/HelloMeasure_measureWidth(537): specSize = 100
12-05 01:48:14.678: I/HelloMeasure_measureWidth(537): specSize = 100
12-05 01:48:14.688: I/HelloMeasure_measureWidth(537): specSize = 100
12-05 01:48:14.758: I/HelloMeasure_measureWidth(537): specSize = 100
12-05 01:48:14.768: I/HelloMeasure_measureWidth(537): specSize = 100
12-05 01:48:14.768: I/HelloMeasure_measureWidth(537): specSize = 100
12-05 01:48:14.768: I/HelloMeasure_measureWidth(537): specSize = 100
12-05 01:48:14.678: I/HelloMeasure_measureHeight(537): specSize = 460
12-05 01:48:14.678: I/HelloMeasure_measureHeight(537): specSize = 460
12-05 01:48:14.678: I/HelloMeasure_measureHeight(537): specSize = 150
12-05 01:48:14.688: I/HelloMeasure_measureHeight(537): specSize = 150
12-05 01:48:14.758: I/HelloMeasure_measureHeight(537): specSize = 460
12-05 01:48:14.768: I/HelloMeasure_measureHeight(537): specSize = 460
12-05 01:48:14.768: I/HelloMeasure_measureHeight(537): specSize = 150
12-05 01:48:14.768: I/HelloMeasure_measureHeight(537): specSize = 150
想请教一下, 为什么宽measure的结果都是我rl设定的宽
但是高measure的结果却有rl设定的高跟整个Activity的高两种数值?
程式码如连结:http://pastebin.com/1j7P4K4h
另想请教, 我看了Android的文件,
UNSPECIFIED
The parent has not imposed any constraint on the child. It can be whatever
size it wants.
EXACTLY
The parent has determined an exact size for the child. The child is going to
be given those bounds regardless of how big it wants to be.
AT_MOST
The child can be as large as it wants up to the specified size.
并测试了以下的结果
Fill_Parent > MeasureSpec.Exactly
Match_Parent > 同上
Warap_Content > MeasureSpec.AT_Most
MeasureSpec.AT_Most, MeasureSpec.Exactly与我理解的Android文件一样的结果
但什么时候会有 UNSPECIFIED 的发生呢?
谢谢各位前辈!