推荐答案复制/粘贴 这个答案,以便社区可以看到提供的解决方案:Copy/paste this answer so that the community can see the provided solutions:@RoyiNamir 这是预期的行为.发生的情况是,默认情况下,根布局将具有有效宽度(和高度)作为屏幕尺寸.如果您希望有效宽度大于屏幕宽度,则需要明确创建更宽的容器.@RoyiNamir this is expected behavior.What is happening is that by default the root layout will have an effective width (and height) as the screen size.You need to explicitly create the wider container if you want to have an effective width larger than the screen width.有几种方法可以实现这一点.- 使用固定宽度的容器 - demo Playground hereThere are several approaches on how to achieve that.- use container with fixed width - demo Playground here<GridLayout rows="auto, *" columns="600" backgroundColor="lightgray"> <Button row="0" text="animate" (tap)="animate()"></Button> <StackLayout row="1" orientation="horizontal" #myStack> <StackLayout width="300" backgroundColor="red"> <Label text="Label"></Label> </StackLayout> <StackLayout width="300" backgroundColor="green"> <Label text="Label"></Label> </StackLayout> </StackLayout></GridLayout>请注意,我们的容器 GridLayout 将 columns 设置为 600.Note that our container GridLayout has columns set to 600.另一种选择是不创建固定大小的容器来使用 ScrollView(它将测量其子项,因此子项应具有预定义的大小 - 在您的情况下为 width="300") - 演示游乐场在这里在上面的示例中,不需要容器元素(仅用于创建动画按钮).ScrollView 将测量其子项(300 + 300 = 600 宽度)并占用所需空间.In the example above the container element is not needed (used just to create the animate Button).The ScrollView will measure its children (300 + 300 = 600 width) and will take the space needed. 这篇关于Nativescript Stacklayout 布局不正确?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!