2012-01-19 11 views
1

私はLWUITを使用してJ2MEアプリケーションを作成しています。私はGridLayoutを使用してコントロールを追加しましたが、調整されていません。LWUITのUIアラインメント?

コード:事前に

flowLayout = new FlowLayout(); 
     roundsPage.setLayout(flowLayout); 


    try { 
     image = image.createImage("/11.png"); // All image 40 x 40 
     starImage = Image.createImage("/j1.png"); 
     smileImage = Image.createImage("/j2.png"); 
     imgClock = Image.createImage("/clock.jpg"); 
     imageTeam = Image.createImage("/name.png");   

    } catch (IOException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    }   

    dateLabel=new Label("14-02-2012, Round1   "); 
    dateLabel.getStyle().setBgColor(0x8b8989); 
    dateLabel.getStyle().setFgColor(0xffffff); 
    roundsPage.addComponent(dateLabel); 

    //int screenWidth = Display.getInstance().getDisplayWidth(); 

    Container tabContainer1 = new Container(new BoxLayout(BoxLayout.Y_AXIS)); 
     tabContainer1.addComponent(new Button("Click")); 
     tabContainer1.addComponent(new Button("Click")); 
     tabContainer1.addComponent(new Button("Click")); 
     tabContainer1.addComponent(new Button("Click"));   


    Container tabContainer2 = new Container(new BoxLayout(BoxLayout.X_AXIS)); 
     team1=new Label(starImage); 
     team1.setText("Villarreal"); 
     team1.setTextPosition(Component.BOTTOM); 
     //team1.setWidth(10); 
     //team1.getStyle().setFont(Font.createSystemFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN ,Font.SIZE_SMALL)); 
     tabContainer2.addComponent(team1); 
     tabContainer2.setWidth(100); 

     clockLabel=new Label(imgClock); 
     clockLabel.setText("18:00"); 
     clockLabel.setTextPosition(Component.RIGHT);    
     tabContainer2.addComponent(clockLabel); 

     teamLabel=new Label(imageTeam); 
     teamLabel.setText("El Madrigal"); 
     teamLabel.setTextPosition(Component.RIGHT); 
     tabContainer2.addComponent(teamLabel); 

     team2=new Label(smileImage); 
     team2.setText("Betis"); 
     team2.setTextPosition(Component.BOTTOM); 
     team2.setFocusable(true); 
     tabContainer2.addComponent(team2); 

    Container tabContainer3 = new Container(new BoxLayout(BoxLayout.Y_AXIS));   
     tabContainer3.addComponent(new Button("Click")); 
     tabContainer3.addComponent(new Button("Click")); 
     tabContainer3.addComponent(new Button("Click")); 
     tabContainer3.addComponent(new Button("Click"));   

    TabbedPane tabbbed = new TabbedPane(); 
    tabbbed.addTab(null, image, tabContainer1); 
    tabbbed.addTab(null, image, tabContainer2); 
    tabbbed.addTab(null, image, tabContainer3); 
    roundsPage.addComponent(tabbbed); 

感謝。

答えて

0

このような使用はしないでください。"14-02-2012, Round1 "ディスプレイの幅を取得し、preferredWをdateLabelに設定します。画面幅を取得するには、

int width = Display.getInstance().getDisplayWidth();を使用します。

TabbedPaneも使用しないでください。 Tabsを使用してください。 addTabにボタンを追加し、ボタンの幅を設定します。 TabbedPaneを使用すると、各タブは同じ幅と高さを持つためです。それは問題だ。

+2

投票の理由がありますか? : -/ – bharath

+0

私は投票をしなかった? ラベルと画像に幅を適用する方法。私は使用しました int width = Display.getInstance()。getDisplayWidth(); dateLabel.setWidth(width); – selladurai

+0

'Label'にはsetPreferredW(...)を使います。イメージを 'Button'にセットし、あなたが望むようにpreferredWを設定します。 – bharath