Question

I'm trying to create a HorizontalFieldManager in blackberry app, I want fields to be left aligned which is HFM's default layout but then I want to display one BitmapField right aligned, setMargin(0, 0, 0, Display.getWidth() - bitmap.getWidth()) works fine until I add other Fields in the manager, any ideas please

Was it helpful?

Solution

That's a bit hacky, normally the children are the ones who define the alignment inside the parent manager..

You create the hfm using all width available:

    HorizontalFieldManager hfm = new HorizontalFieldManager(Field.USE_ALL_WIDTH);

Then you add the fields (or managers) aligned to left:

    hfm.add(new LabelField("Left", Field.FIELD_LEFT));

And then you add the fields that must be aligned right. I'm using labels here, but every class extending Field (including managers) has a constructor accepting flags as argument:

    hfm.add(new LabelField("Right", DrawStyle.RIGHT | Field.USE_ALL_WIDTH));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top