BitmapField
1 つを画面全体の中央に表示し、もう 1 つを画面の下部に表示したいと考えています。
正しい UI を生成できません。
私はこのように試しました-これを使用すると、1つのビットマップを下に配置できますが、中央を維持することはできませんBitmapField
。
誰でもこれを解決するのを手伝ってください。
VerticalFieldManager vfm = new VerticalFieldManager(VerticalFieldManager.USE_ALL_HEIGHT
| VerticalFieldManager.USE_ALL_WIDTH) {
//Override the paint method to draw the background image.
public void paint(Graphics graphics) {
graphics.setBackgroundColor(Color.DEEPSKYBLUE);
graphics.clear();
super.paint(graphics);
}
};
add(vfm);
HorizontalFieldManager customManager = new HorizontalFieldManager(HorizontalFieldManager.USE_ALL_WIDTH)
{
/* (non-Javadoc)
* Applying background color for that Manager
* @see net.rim.device.api.ui.Manager#paint(net.rim.device.api.ui.Graphics)
*/
public void paint(Graphics graphics)
{
graphics.setBackgroundColor(Color.DEEPSKYBLUE);//blue
graphics.clear();
super.paint(graphics);
}
/* (non-Javadoc)
* Placing the Fields
* @see net.rim.device.api.ui.container.HorizontalFieldManager#sublayout(int, int)
*/
protected void sublayout(int width, int height) {
setPositionChild(getField(0), 0, 0);
layoutChild(getField(0), getField(0).getPreferredWidth(),
getField(0).getPreferredHeight());
setPositionChild(getField(1),
Display.getWidth()/2 - getField(1).getPreferredWidth()/2,
0);
layoutChild(getField(1), getField(1).getPreferredWidth(),
getField(1).getPreferredHeight());
setPositionChild(getField(2),
Display.getWidth() - getField(2).getPreferredWidth(),
0);
layoutChild(getField(2), getField(2).getPreferredWidth(),
getField(2).getPreferredHeight());
setExtent(width, 50);
}
};
//To display About icon
final Bitmap bmp1 = Bitmap.getBitmapResource("a.png");
BitmapField bmpfield1 = new BitmapField(bmp1, BitmapField.FOCUSABLE | BitmapField.FIELD_LEFT){
//To Perform action on clicking the bitmap field
protected boolean navigationClick(int status, int time)
{
UiApplication.getUiApplication().pushScreen(new AboutScreen());
onUnfocus();
return true;
}
protected void onFocus(int direction) {
super.onFocus(direction);
}
protected void onUnfocus() {
super.onUnfocus();
invalidate();
}
};
//To display Help icon
final Bitmap bmp2 = Bitmap.getBitmapResource("b.png");
BitmapField bmpfield2 = new BitmapField(bmp2,BitmapField.FOCUSABLE | BitmapField.FIELD_RIGHT){
//To Perform action on clicking the bitmap field
protected boolean navigationClick(int status, int time)
{
UiApplication.getUiApplication().pushScreen(new
OpenBrowserScreen(""));
onUnfocus();
return true;
}
protected void onFocus(int direction) {
super.onFocus(direction);
}
protected void onUnfocus() {
super.onUnfocus();
invalidate();
}
};
//To display Title Bitmap
final Bitmap bmp3 = Bitmap.getBitmapResource("c.png");
BitmapField bmpfield3 = new BitmapField(bmp3, BitmapField.FIELD_VCENTER | BitmapField.FOCUSABLE);
bmpfield3.setBitmap(bmp3);
//Adding the Three fields to the manager
customManager.add(bmpfield1);
customManager.add(bmpfield3);
customManager.add(bmpfield2);
vfm. add(customManager);
bmpfield3.setFocus();
HorizontalFieldManager hfm = new HorizontalFieldManager(Field.FIELD_HCENTER);
//VerticalFieldManager vfmfields = new VerticalFieldManager(VerticalFieldManager.FIELD_HCENTER|Field.USE_ALL_HEIGHT);
bmpscan = Bitmap.getBitmapResource("test1.png");
bmpfieldscan = new BitmapField(bmpscan,BitmapField.FOCUSABLE |Field.FIELD_VCENTER);
hfm.add(bmpfieldscan);
vfm.add(hfm);
HorizontalFieldManager hfmacnts = new HorizontalFieldManager(HorizontalFieldManager.USE_ALL_HEIGHT | HorizontalFieldManager.FIELD_BOTTOM);
bmpacnts = Bitmap.getBitmapResource("test2.png");
bmpfieldacnts = new BitmapField(bmpacnts,BitmapField.FOCUSABLE | Field.FIELD_BOTTOM) {
protected boolean navigationClick(int status, int time)
{
return true;
}
};
hfmacnts.add(bmpfieldacnts);
vfm.add(hfmacnts);