In my xml I specified wrap_content for both the width and height but when I override the onMeasure function the width and height that are passed to it is -2147483348 which oddly is 300 > Integer.MIN_VALUE is there a reason for this? why is it not integer.MIN_VALUE or 0 if I didn’t have anything inside it. BTW this is a custom view that i’m making so I have to do setMeasuredDimension I believe.
Share
The arguments to
onMeasureare not the available width and height, but an encoding of the available width and height along with flags about how those values are supposed to be used. You decode them using theView.MeasureSpecclass:The mode will be one of
AT_MOST,EXACTLY, orUNSPECIFIED. See the docs for how you are supposed to use this. In particular, if the mode is notUNSPECIFIEDyou must not use a value greater than the size for that dimension when you callsetMeasuredDimension.