将 Xamarin Forms 中的布局粘贴到底部 [英] Stick Layout in Xamarin Forms to bottom

查看:26
本文介绍了将 Xamarin Forms 中的布局粘贴到底部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在以 Xamarin 形式制作应用程序,但在将布局粘贴到设备底部时遇到了一些问题.我认为 AbsoluteLayout 会起作用,但我无法理解它是如何工作的.所以我做了一个RelativeLayout,我用我想要填充的元素填充但现在我似乎无法让它一直粘在设备的底部.

I'm making an application in Xamarin forms but I have some trouble sticking a layout to the bottom of the device. I thought an AbsoluteLayout would work, but I cannot grasp how it works. So I made a RelativeLayout which I filled with the elements I wanted to fill but now I cannot seem to get it working on sticking to the bottom of the device at all time.

下面是一张截图,希望能让事情更清楚一点.我有一个 stacklayout,我用 headerlayout 和 contentlayout 填充它.但是如果我只是将页脚布局添加到堆栈布局中,它不会被粘贴到页面的底部,而是(逻辑上)就在前一个孩子的后面.现在我认为 Absolutelayout 可以解决问题,但我似乎无法掌握它的功能以及 Layoutflags 和边界.有人可以帮我吗?

Below is a screenshot to make things hopefully a little bit more clear. I have a stacklayout which I fill with the headerlayout and the contentlayout. But if I just add the footerlayout to the stacklayout, it will not be sticked to the bottom of the page but (logically) just behind the previous child. Now I think an Absolutelayout would do the trick, but I cannot seem to grasp the functionality and the Layoutflags and bounds of it. Could someone help me out?

推荐答案

<StackLayout>
  <StackLayout Orientation="Horizontal" VerticalOptions="Start">
    <!-- top controls -->
  </StackLayout>

  <StackLayout VerticalOptions="CenterAndExpand">
    <!-- middle controls -->
  </StackLayout>

  <StackLayout Orientation="Horizontal" VerticalOptions="End">
    <!-- bottom controls -->
  </StackLayout>
</StackLayout>

确保使用 Expand 选项的孩子不超过一个以获得最佳性能.

Make sure to have no more than one child with Expand options for best performance.

这篇关于将 Xamarin Forms 中的布局粘贴到底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆