I need to make a screen like this:
The only thing I need to add to my code
is something to put the background image
behind those buttons.
This is what I have so far:
public class PruebaScreen extends MainScreen{
public PruebaScreen(){
LabelField title = new LabelField("Screen Title");
title.setPadding(40, 0, 20, 60);
BitmapField btn1 = new BitmapField(Bitmap.getBitmapResource("btn-1.png"));
btn1.setPadding(2,0,3,0);
BitmapField btn2 = new BitmapField(Bitmap.getBitmapResource("btn-2.png"));
btn2.setPadding(2,0,3,0);
add(title);
add(btn1);
add(btn2);
}
}
How should I do to put those two buttons over the background image?. The image should not take all the screen.
Thanks in advance.
You should
VericalFieldManager)Here is a code snippet that creates a solid color background:
LabelField title = new LabelField("Screen Title");
title.setPadding(40, 0, 20, 60);
VerticalFieldManager vfm = new VerticalFieldManager(USE_ALL_WIDTH);
vfm.setBackground(BackgroundFactory.createSolidBackground(Color.BLUE));
vfm.setPadding(20, 0, 20, 0);
ButtonField btn1 = new ButtonField("Option 1");
btn1.setPadding(2, 0, 3, 0);
ButtonField btn2 = new ButtonField("Option 2");
btn2.setPadding(2, 0, 3, 0);
add(title);
vfm.add(btn1);
vfm.add(btn2);
add(vfm);
To make the background a bitmap, just replace
vfm.setBackground(BackgroundFactory.createSolidBackground(Color.BLUE));
with
vfm.setBackground(BackgroundFactory.createBitmapBackground(YOUR BITMAP);

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With