xamarin.forms shell中的scrollview会自动保证到顶部吗?

问题描述 投票:0回答:1

我发现用xamarin.forms shell。 scrollview将自动保留到顶部,我无法更改它。有什么方法可以更改它吗?

我尝试了很多解决方案并进行了搜索,但没有人可以解决它。似乎它会为标题栏(操作栏)自动保证金。我已经隐藏了导航栏。

无论指定高度还是x,y位置都不起作用。

<ContentPage.Content>
    <StackLayout>
          <ScrollView>
             <Image Source="a.png" VerticalOptions="StartAndExpand" />
          </ScrollView>
    </StackLayout>
</ContentPage.Content>

enter image description here

我想将图像放到顶部,不要留下空白区域。

xamarin.forms
1个回答
1
投票

你有白色空间的部分叫做Safe Area

默认情况下,Xamarin Forms不使用安全区域。

但是如果你想以任何方式使用它,可以这样做:

On<Xamarin.Forms.PlatformConfiguration.iOS>().SetUseSafeArea(true);

另外,使用Statement using Xamarin.Forms.PlatformConfiguration.iOSSpecific;添加以下内容

同样可以通过你的ContentPage上的XAML这样做:

<?xml version="1.0" encoding="UTF-8"?> 
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core" 
ios:Page.UseSafeArea="true" >

要详细了解其工作原理,您可以查看此blog by Xamarin

© www.soinside.com 2019 - 2024. All rights reserved.