09-17-2012 06:16 PM
Hey all,
Been picking at this for quite some time, using solutions found on many forums. Still unable to get it right. I have this simple about screen in my application, and i simply want all the lines of text to be centered on screen Horizontally, and Vertically too if that works. What am I doing wrong here?
package com.rim.samples.device.helloworlddemo; import net.rim.device.api.system.Display; import net.rim.device.api.ui.DrawStyle; import net.rim.device.api.ui.Field; import net.rim.device.api.ui.Manager; import net.rim.device.api.ui.component.RichTextField; import net.rim.device.api.ui.container.MainScreen; import net.rim.device.api.ui.container.VerticalFieldManager; public class AboutScreen extends MainScreen { /** * */ public AboutScreen() { super(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR); VerticalFieldManager vfm = new VerticalFieldManager(USE_ALL_WIDTH | FIELD_HCENTER){ protected void sublayout(int maxWidth, int maxHeight) { super.sublayout(Display.getWidth(),Display.getHeig ht()); setExtent(Display.getWidth(),Display.getHeight()); } }; vfm.add(new RichTextField("Lead Developer - Xxxx Xxxxxxx", Field.NON_FOCUSABLE | Field.FIELD_HCENTER)); vfm.add(new RichTextField("For Support - xxxxxxxx@gmail.com", Field.NON_FOCUSABLE | Field.FIELD_HCENTER)); vfm.add(new RichTextField("Follow us on Twitter - @xxxxxxxxxx", Field.NON_FOCUSABLE | Field.FIELD_HCENTER)); vfm.add(new RichTextField("Version - 1.0.0", Field.NON_FOCUSABLE | Field.FIELD_HCENTER)); add(vfm); } }
Thanks,
Theodore M.
Solved! Go to Solution.
09-18-2012 10:22 AM
Could you try putting the RichTextField in a GridFieldManager?
so it would look something like
o=empty field
x=richtextfield
----- Grid Field Manager ----
|o|o|o|
|o|x|o|
|o|o|o|
09-18-2012 03:34 PM
I appreciate the response, but I dont feel that would solve my problem. All i need to to is align the text in the horizontal center of the screen. There must be some error in the properties i set in my code above or something.
09-18-2012 04:02 PM
Try creating your RichTextField with TEXT_JUSTIFY_HCENTER (TEXT_ALIGN_HCENTER before OS 7.0) flag. FIELD_HCENTER tells the Manager where to put the field during layout. Those TEXT_ALIGN/TEXT_JUSTIFY flags tell the field how to display the text.
You might want to drop FIELD_HCENTER and use USE_ALL_WIDTH combined with that TEXT_JUSTIFY/TEXT_ALIGN flag - see what looks better.
09-18-2012 04:08 PM
K so i ended up solving it easily using the following property in each RichTextField object-
RichTextField.TEXT_ALIGN_HCENTER
And that solved it all.
03-01-2013 10:56 AM
_rtf = new RichTextField("BlueTooth connection stop...", RichTextField.NON_FOCUSABLE | RichTextField.TEXT_JUSTIFY_HCENTER);
RichTextField.TEXT_ALIGN_HCENTER is Deprecated.
Cheers.