【问题标题】:Xaml Xamarin Forms Absolute Layout OverlapXaml Xamarin 形成绝对布局重叠
【发布时间】:2017-07-20 23:15:00
【问题描述】:

鉴于上图,我将如何设置我的绝对布局? 我想让我的蓝色绝对布局与红色边框绝对布局重叠。我知道有一个 doc 解释了 AbsoluteLayouts 的工作原理,但我仍然没有 100% 完全理解它。

我已尝试按以下方式设置布局,但蓝色方块始终隐藏。

使用下面的代码,我根本看不到蓝色布局。

<AbsoluteLayout>
 <AbsoluteLayout x:Name="BlueSquare">
    <StackLayout> (Asumme there is a list of things in here) </StackLayout>
 </AbsoluteLayout>
 <AbsoluteLayout x:Name="RedBorderArea">
    <StackLayout> (Asumme there is another list of stuff in here) </StackLayout>
 </AbsoluteLayout>
</AbsoluteLayout>

【问题讨论】:

  • 您尝试过使用“BlueSquare”绝对布局的 Z-Index 吗?
  • 如果z-index指的是我添加孩子的顺序,我想我可以尝试调用这个方法。 developer.xamarin.com/api/member/… 不过我不确定这是否是正确的解决方案。
  • 鉴于上面提供的信息,我知道您希望它是什么样子,但我不知道它“实际”是什么样子。当你说蓝色方块被隐藏时,我假设你可以看到它,但它在你的红色方块后面。在这种情况下,首先要研究的是它沿 Z 轴的布局。 =)

标签: forms xaml xamarin xamarin.forms


【解决方案1】:

修改后,我需要最后添加蓝色方形布局,并删除了 RedSquares 父布局。

<AbsoluteLayout>
    <StackLayout x:Name="RedBorderArea" AbsoluteLayout.LayoutFlags="All" AbsoluteLayout.LayoutBounds="0.5,0.5,1,1"> (Asumme there is another list of stuff in here) </StackLayout>
    <AbsoluteLayout x:Name="BlueSquare" LayoutFlags="PositionProportional, WidthProportional" LayoutBounds="1,0,1,1">
       <StackLayout> (Asumme there is a list of things in here) </StackLayout>
    </AbsoluteLayout>
</AbsoluteLayout>

【讨论】:

    猜你喜欢
    • 2018-01-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-12
    • 2017-01-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多