【问题标题】:How to "Overlap" two Layouts Nativescript如何“重叠”两个布局 Nativescript
【发布时间】:2020-06-18 15:59:07
【问题描述】:

我需要这个使用 Nativescript 的布局,但我不知道该怎么做。 红框必须在自定义位置的黑框前面。

非常感谢!

【问题讨论】:

    标签: android ios layout nativescript


    【解决方案1】:

    您可以使用AbsoluteLayout 作为包含红色和黑色框的容器。下面的Label 只是黑色和红色框的占位符。使用AbsoluteLayout,您可以使用lefttop 属性,类似于在css 中为position: absolute 执行的操作。需要注意的是 html 中元素的顺序是它的堆叠顺序(就 z-index 而言) - 它在 html 中越往下,z-index 就越高。

    <AbsoluteLayout width="210" height="210">
    
        <!-- black box -->
        <Label text="no margin" left="10" top="10" width="100" height="100"/>
    
        <!-- red box -->
        <Label text="margin='30'" left="10" top="10" margin="30" width="100" height="90"/>
    
      </AbsoluteLayout>
    

    旁注:您也可以使用GridLayout 来分层元素(如果您不需要绝对定位属性,例如lefttop

    【讨论】:

      猜你喜欢
      • 2013-11-23
      • 2021-09-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多