我正在努力掌握Anchor布局的用法。我有以下代码构造函数:
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.使用相应的TexTBox View 创建标签 View 。
2.获取TextBox View 以占据浏览器空间的其余部分,这些 View 随浏览器宽度的变化而变化。
谢谢
最佳答案
AnchorLayout不是答案。相反,LinearLayout应该会有所帮助。
关于dart - 如何使用 anchor 布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16319186/