Reworked onMeasure for proper wrap_content support

This time this pull request only contains this patch. Sorry but I have little experience with github flows :)