Second method is a horrible approach (messing with VerticalFieldManager's height will get you a lot of problems).
Try the first method again, but this time call super.layout
first:
DateField dtf = new DateField(label, defaultDateTime, DateField.DATE_TIME | DrawStyle.LEFT | DrawStyle.TOP | Field.FOCUSABLE | Field.READONLY )
{
protected void layout(int width, int height) {
super.layout(width, height);
Bitmap bmp = UIElements.GetBitmap(UIElements.IMG_DROPDOWN_BG, true);
width = bmp.getWidth();
height = bmp.getHeight();
super.setExtent(width, height);
}
};
Notice that using this approach you might also get glitches, as you are blindly overriding a method without considering the rest of the class. To do this safely you would need to have access to the parent class source, and you don't.
I'd suggest to extend HorizontalFieldManager
(override sublayout
) to have a fixed height (Never VFM because the scrolling goes in the same direction you are trying to make fixed). Then place inside a regular date field that uses all the available height (pass the flag Field.USE_ALL_HEIGHT
in the constructor).