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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.