如何使用Rikulo Anchor Layout更改TextBox视图的宽度

时间:2013-04-28 03:14:49

标签: dart rikulo

我是Dart和Rikulo的新手。

class NameView extends Section
{
  View parentVu;

  // the inputs
  DropDownList titleDdl, suffixDdl; 
  TextBox firstNameTBox, middleNameTBox, lastNameTBox;

  // the labels
  TextView titleLbl, firstNameLbl, middleNameLbl, lastNameLbl, suffixLbl;

  List<String> titles = [ 'Dr', 'Hon', 'Miss', 'Mr', 'Mrs', 'Prof', 'Sir' ];
  List<String> suffixes = ['I', 'II', 'III', 'IV', 'Junior', 'Senior'];

  NameView()
  {
     parentVu = new View()
     ..style.background = 'cyan'
     ..addToDocument();

     titleLbl = new TextView( 'Title' );
     parentVu.addChild( titleLbl );

     titleDdl = new DropDownList( model : new DefaultListModel( titles ) )
       ..profile.anchorView = titleLbl
       ..profile.location = 'east center';
     parentVu.addChild( titleDdl );

     firstNameLbl = new TextView( 'First' )
       ..profile.anchorView = titleDdl
       ..profile.location = 'east center';
     parentVu.addChild(firstNameLbl );

     firstNameTBox = new TextBox( null, 'text' )
      ..profile.anchorView = firstNameLbl
      ..profile.location = 'east center';
      //..profile.width = 'flex';
     parentVu.addChild( firstNameTBox );
}

该程序呈现。但是,它不使用浏览器的整个宽度(FireFox)。 我试过TextBoxes     profile.width ='flex'

但它不起作用。

感谢任何帮助。

2 个答案:

答案 0 :(得分:0)

火狐?你用Dartium测试了吗?请注意,您必须先将其编译为JS,然后才能使用Dartium以外的浏览器进行测试。

  BTW,从你的实现来看,NameView似乎与parentVu根本没有关系。如果它只是一个控制器,它不需要从Section扩展(即,它不必是一个视图)。

答案 1 :(得分:0)

如果视图锚定到另一个视图,则位置和大小都将取决于它所锚定的视图。在您的情况下,如果为TextBox指定flex,则其宽度将与FirstNameLb1相同。这就是为什么它如此之小。

您可以收听布局事件,例如:

 firstNameTBox.on.layout.listen((_) {
    firstNameTBox.width = parentVu.width;
 });
  

注意:您需要进行一些计算以获得正确的宽度。

另见Layout Overview