Code on GitHub: https://github.com/TheWayOfCoding/tutorialsandsnippets/tree/master/Android/SizeBeforeViewCreation
My website Article: http://thewayofcoding.com/2016/04/get-the-size-of-a-custom-view-before-display/
Tutorial code license:
http://thewayofcoding.com/tutorial-code-license/
In this video I go over making a custom view where we can get the size of the view before it starts fully running. This is helpful when you want to do screen calculations beforehand. In my case I had a simple game's display code in the view that needed screen tile calculations before everything started. We use ViewTreeObserver.OnGlobalLayoutListener to make it happen.