2012-03-21 147 views
0

我想墊的電子郵件字段下面的代碼片段:黑莓場填補

emailField = new BasicEditField(BasicEditField.FILTER_EMAIL|Field.FIELD_HCENTER|TextField.NO_NEWLINE|Field.HIGHLIGHT_FOCUS|Field.FOCUSABLE); 
    emailField.setLabel("Email: "); 
    emailField.setPadding(5, 5, 5, 5); 
    emailField.setBorder(BorderFactory.createRoundedBorder(new XYEdges(10, 10, 10, 10), 0x0083B0D7, Border.STYLE_SOLID)); 

是否有墊一個適當的方式,使得顯示的邊框和之間沒有保證金領域背景?

+0

歡迎#1。圖像附件固定。 – menjaraz 2012-03-21 13:58:41

+0

檢查我的更新我的答案。 – mrvincenzo 2012-03-22 10:16:03

回答

4

嘗試使用setMargin(5,5,5,5)而不是setPadding(5,5,5,5)

Field#setMargin()
保證金是現場外的區域,邊界之後。由於這些重疊,經理正確分配利潤率。

Field#setPadding()
填充是內容和邊框之間的區域內的區域。

Field#SetBorder()
邊框是填充之外和邊距之前的區域內的區域。

enter image description here

UPDATE
你是正確的,與setMargin()更換setPadding()而已,並沒有產生預期的結果。原因是您正在使用的Border,更準確地說它的厚度()和樣式(STYLE_SOLID)。減小邊框厚度至並將其更改爲STYLE_FILLED

上述變化 enter image description here

而且現在的代碼片段後:

public class PlayingWithBorders extends MainScreen { 
    public PlayingWithBorders() { 
     super(NO_VERTICAL_SCROLL | NO_HORIZONTAL_SCROLL | USE_ALL_HEIGHT | USE_ALL_WIDTH); 

     VerticalFieldManager vfm = new VerticalFieldManager(USE_ALL_HEIGHT | USE_ALL_WIDTH); 
     vfm.setBackground(BackgroundFactory.createSolidBackground(Color.CYAN)); 

     BasicEditField emailField = new BasicEditField(); 
     emailField.setLabel("Email: "); 
     emailField.setPadding(5, 5, 5, 5); 
     emailField.setMargin(5, 5, 5, 5); 
     emailField.setBorder(BorderFactory.createRoundedBorder(new XYEdges(3, 3, 3, 3), 0x0083B0D7, Border.STYLE_FILLED)); 
     emailField.setBackground(BackgroundFactory.createSolidBackground(Color.WHITE)); 

     BasicEditField passwordField = new BasicEditField(); 
     passwordField.setLabel("Password: "); 
     passwordField.setPadding(5, 5, 5, 5); 
     passwordField.setMargin(5, 5, 5, 5); 
     passwordField.setBorder(BorderFactory.createRoundedBorder(new XYEdges(3, 3, 3, 3), 0x0083B0D7, Border.STYLE_FILLED)); 
     passwordField.setBackground(BackgroundFactory.createSolidBackground(Color.WHITE)); 

     vfm.add(emailField); 
     vfm.add(passwordField); 
     add(vfm); 
    } 
+0

仍然一樣。沒有改變。 – kehers 2012-03-22 08:49:50

+0

@OpeyemiObembe我已經更新了我的答案 – mrvincenzo 2012-03-22 22:16:00