【问题标题】:Place a label at coordinates in Titanium在 Titanium 中的坐标处放置标签
【发布时间】:2013-07-18 11:34:32
【问题描述】:

我创建了一个标签,并希望将其放置在特定坐标上。有没有办法可以直接设置 x 和 y 坐标以将标签放置在 Titanium 中。

【问题讨论】:

    标签: label titanium coordinates titanium-mobile


    【解决方案1】:

    非常简单,只需将 topleft 值设置为您各自的 Y 和 X 值。这些是相对于标签父级的,如果您将父级layout 属性设置为composite 以外的任何值,则它们将无法按预期工作:

    var label1 = Ti.UI.createLabel({
      color: '#900',
      font: { fontSize:48 },
      text: 'A simple label',
      textAlign: Ti.UI.TEXT_ALIGNMENT_CENTER,
      top: 30, // Your Y coordinate
      left : 20, // Your X coordinate
      width: Ti.UI.SIZE, height: Ti.UI.SIZE
    });
    

    Check this guide for more information 关于视图和定位。

    【讨论】:

      猜你喜欢
      • 2017-01-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-27
      • 2021-10-15
      • 2014-11-29
      相关资源
      最近更新 更多