2013-05-01 73 views
1

我很努力地掌握錨佈局的使用。我有以下代碼構造:如何使用錨佈局

LokationView() 
{ 


    buildCityUi(); 
    buildRegionUi(); 



} 

buildCityUi() 
{ 
    cityLbl = new TextView('City'); 
    addChild(cityLbl); 

    cityTxBx = new TextBox(null, 'text') 
    ..profile.width = 'flex ' 
    ..profile.anchorView = cityLbl 
    ..profile.location = 'east center' 
    ..on.layout.listen((_) 
    { 
     cityTxBx.width = 200; 
     cityTxBx.requestLayout(); 
    }); 


    addChild(cityTxBx); 

} 

buildRegionUi() 
{ 

    regionLbl = new TextView('Region') 
    ..profile.anchorView = cityLbl 
    ..profile.location = 'south start';  
    addChild(regionLbl); 

    regionTxBx = new TextBox(null, 'text') 
    ..profile.width = 'flex 1' 
    ..profile.anchorView = regionLbl 
    ..profile.location = 'east center'; 
    addChild(regionTxBx); 
} 

我試圖得到如下進行: 1.創建有相應的文本框視圖標籤視圖。 2.獲取TextBox視圖以佔用瀏覽器空間的其餘部分,視圖隨着瀏覽器寬度的變化而變化。

感謝

回答

0

AnchorLayout是不能解決問題的。相反,LinearLayout應該有所幫助。

+0

非常感謝湯姆。 – 2013-05-02 03:56:58