I want to create buttons centered horizontally on background created from bitmap. Right now I have vertical field manager with background:
vertical=new VerticalFieldManager()
{
protected void paint(Graphics g)
{
g.drawBitmap(0, 0, Display.getWidth(), Display.getWidth(), scaleBit, 0, 0);
super.paint(g);
}
protected void sublayout(int maxWidth, int maxHeight)
{
super.sublayout(Display.getWidth(), Display.getWidth());
setExtent(Display.getWidth(), Display.getWidth());
}
};
but when I add paramethers like FIELD_HCENTER | Field.USE_ALL_WIDTH to vertical field manager constructor nothing happens when I add buttons, so how should it be done?
If this is on a
MainScreenyou don't need to add theVerticalFieldManageras the screen will have one as its root anyways. I'm going to answer as though the manager needs to be separate as you have it, but this should work either way.You don't need to override the
paintandsublayoutmethods of yourVerticalFieldManager. You should be able to get what you want with standard methods.I think the big issue you might be having is a scrollable parent that causes your manager, or button to be placed in the center of and extremely large scroll area.