Instead of overriding onMeasure(), use setLayoutParams() for setting size of view
use onSizeChanged instead of ViewTreeObserver