繁体   English   中英

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

[英]How to vary the width of TextBox views using Rikulo Anchor Layout

我是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'

但它不起作用。

任何帮助表示赞赏。

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

顺便说一句,从您的实现来看,NameView似乎根本与parentVu不相关。 如果它只是一个控制器,则不需要从Section扩展(即,它不必是视图)。

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

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

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

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

另请参阅布局概述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM