05-09-2009 11:47 PM
I have been battling for a while to get background images work correctly. Here is what I do:
VerticalFieldManager vfm = new VerticalFieldManager();
Bitmap map = Bitmap.getBitmapResource("MyImage.jpg");
Background bg = BackgroundFactory.createBitmapBackground(map);
vfm.setBackground(bg);
This works but has a pitfall. First of all, it only paints as much as you have fields taking up space, so I have to add blank fields just to take up vertical space. However, on a page with something like a listField, where the height is variable, this can lead to having the background image start to repeat and allow scrolling.
What I want to do is block all scrolling and have the background exactly fill the screen with no scrolling or white blank places.
Am I just going about this wrong? Would realy love some help...
Solved! Go to Solution.
05-10-2009 02:13 AM
Hi Epicdraw,
You can try this.
verticalManager = new VerticalFieldManager(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR) { public void paint(Graphics graphics) { graphics.setBackgroundColor(Color.BLACK); graphics.clear(); super.paint(graphics); } protected void sublayout( int maxWidth, int maxHeight ) { int displayWidth = Display.getWidth(); int displayHeight = Display.getHeight(); super.sublayout( displayWidth, displayHeight); setExtent( displayWidth, displayHeight); } };
Regards
Bikas
05-10-2009 02:15 AM
05-10-2009 02:22 AM
Hi,
Hope this piece of code will help you.Instead of using Background API i had used paint () for this purpose as this API was made available in JDE 4.7 only.
import net.rim.device.api.ui.container.MainScreen; import net.rim.device.api.ui.container.VerticalFieldManag
er; import net.rim.device.api.ui.component.BitmapField; import net.rim.device.api.ui.Graphics; import net.rim.device.api.ui.Field; import net.rim.device.api.ui.component.ListField; import net.rim.device.api.ui.component.ListFieldCallback; import net.rim.device.api.system.Bitmap; import net.rim.device.api.ui.Manager; class MSBMainScreen extends MainScreen implements ListFieldCallback { String Data[] = {"Task ID","Priority","Task Name","Location","Task Type","State","AAA","BBB","CCCC","DDD","EEE","FFFF ","GGGG","HHHH","IIII"}; private VerticalFieldManager objManager; private Bitmap objBitmap; ListField objList = null; public MSBMainScreen(){ super(); drawComponent(); setTitle( "Inbox Screen" ); objBitmap = Bitmap.getBitmapResource( "watermark.png"); objManager = new VerticalFieldManager( Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR ) { protected void paint( Graphics g ){ int y = MSBMainScreen.this.getMainManager().getVerticalScr oll(); g.drawBitmap( 0, y, objBitmap.getWidth(), objBitmap.getHeight(), objBitmap, 0, 0 ); super.paint( g ); } protected boolean keyDown( int keycode, int status ){ invalidate(); return super.keyDown( keycode, status ); } protected boolean navigationMovement( int dx, int dy, int status, int time ){ invalidate(); return super.navigationMovement( dx, dy, status, time ); } protected int moveFocus(int amount, int status, int time){ invalidate(); return super.moveFocus(amount, status, time); } }; add(objList); super.add( objManager ); } public void add( Field field ){ objManager.add( field ); } public void delete( Field field ){ objManager.delete( field ); } public void drawListRow(ListField listField, Graphics g, int index, int y, int width){ g.drawText(Data[index], /*10*/10, /*CTIAMain.ROW_HEIGHT*index*/y ); } public int indexOfList(ListField listField, String prefix, int start){ return 0; } public Object get(ListField listField, int index){ return Data[index]; } public int getPreferredWidth(ListField listField){ return 0; } private void drawComponent(){ objList = new ListField(Data.length); objList.setCallback(this); } }
05-10-2009 02:34 AM
05-10-2009 02:42 AM
Hi,
Sorry there is on other way.
I am also doing the same thing what you are doing.I had used one verticalFieldManager and overided it's function so that image gets repainted in different secenarios like when you are moving in the list etc.
There might be different solution to this problem but real problem comes when you draw listfield over an image.In that case image do not get repainted properly.For this problem this the only solution.
05-10-2009 02:43 AM
05-10-2009 02:57 AM
Hi,
Hope this will help you.
class LoginScreen extends MainScreen {
//Manager
private VerticalFieldManager _manager;
LoginScreen() {
//Set Background image
_manager = (VerticalFieldManager)getMainManager();
Background bg = BackgroundFactory.createBitmapBackground(Bitmap.getBitmapResource("back.png"));
_manager.setBackground(bg);
}
}Add this manageron your screen do not add any other component in this manager.
Add you fields in other manager and add that manager on screen.
Let me know if this solves your problem or not.
05-10-2009 03:32 AM
05-10-2009 03:59 AM
hi,
Please close the thread.