Improved onMeasure to handle newdisplay configurations.
Minor improvements for horizontal layouts.