为什么 GridLayout 会覆盖整个屏幕?

Why does the GridLayout cover the whole screen?

我有以下 HTML 代码:

<GridLayout>
  <GridLayout #background class="background">
  </GridLayout>

  <StackLayout #initialContainer class="initial-container">
    <Image src="res://logo_login">
    </Image>
    ....
    ....
  </StackLayout>
</GridLayout>

我的问题是关于带有 background class 的 GridLayout。

这是 class 的 CSS:

.background {
  background-image: url("res://apple");
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center;
}

显然这是实际背景(这里是橙色背景,不是徽标!)。

问题 我不明白为什么 GridLayout 会覆盖整个屏幕。即使是这样,我也希望 StackLayout 位于 GridLayout 之后。我已经知道 background-size:cover 覆盖了整个 space,但为什么 GridLayout 也覆盖了整个屏幕?为什么徽标和标题不在我的 CSS 中时显示为绝对定位?

您的外部布局是一个 GridLayout,如果您不指定行和列,则布局内的任何布局或项目将在最左上角的网格单元格中彼此堆叠,分层顺序是它们在 html 中。为了解决这个问题,将你的外部布局换成 StackLayout