试图将 a 的高度DateField
从默认的 53 降低到 32,但无济于事。高度保持不变,结果文本出现在高度较小的背景底部(32)。
我尝试了两种方法:
DateField dtf = new DateField(label, defaultDateTime, DateField.DATE_TIME | DrawStyle.LEFT | DrawStyle.TOP | Field.FOCUSABLE | Field.READONLY )
{
protected void layout(int width, int height)
{
Bitmap bmp = UIElements.GetBitmap(UIElements.IMG_DROPDOWN_BG, true);
width = bmp.getWidth();
height = bmp.getHeight();
super.setExtent(width, height);
super.layout(width, height);
}
};
第二种方法(基于 Stack Overflow 帖子):
public class MyDateManager extends VerticalFieldManager {
protected DateField dateField_ = null;
public MyDateManager(String label, long defaultDateTime) {
super(Manager.FIELD_HCENTER | Manager.FIELD_VCENTER);
dateField_ = new DateField(label, defaultDateTime, DateField.DATE_TIME |
Field.FIELD_HCENTER | DrawStyle.HCENTER | Field.FOCUSABLE | Field.READONLY);
this.add(dateField_);
}
protected void sublayout(int width, int height) {
Bitmap bmp = UIElements.GetBitmap(UIElements.IMG_DROPDOWN_BG, false);
width = bmp.getWidth();
height = bmp.getHeight();
layoutChild(dateField_, width, height);
dateField_.setBackground(BackgroundFactory.createBitmapBackground(bmp, 0, 0, Background.REPEAT_NONE));
int h = dateField_.getHeight();
setExtent(width, height);
}
}
请建议。
谢谢