Xamarin.forms Xamarin.在iOS中形成帧内带负边距且不重叠的图像
框架内的图像,顶部为负边距,用于重叠,但正如您看到的,它在框架边缘切割 更新问题添加整页代码我删除底部部分Xamarin.forms Xamarin.在iOS中形成帧内带负边距且不重叠的图像,xamarin.forms,xamarin.ios,Xamarin.forms,Xamarin.ios,框架内的图像,顶部为负边距,用于重叠,但正如您看到的,它在框架边缘切割 更新问题添加整页代码我删除底部部分 <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:i18n="clr-namespace:AgentWay.Helpers;assembly
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:i18n="clr-namespace:AgentWay.Helpers;assembly=AgentWay"
xmlns:layouts="clr-namespace:AgentWay.Layouts;assembly=AgentWay"
xmlns:controls="clr-namespace:CustomControls.Controls;assembly=CustomControls"
xmlns:base="clr-namespace:AgentWay.Pages;assembly=AgentWay"
NavigationPage.TitleView="{Binding TitleView}"
NavigationPage.HasNavigationBar="{Binding HasNavFlag}"
x:Class="AgentWay.Pages.WelcomePage">
<Grid x:Name="WelcomeScrole" VerticalOptions="Center" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Frame Grid.Row="1" >
<ContentView Grid.Row="0" Margin="0,-80,0,0" >
<Image HeightRequest="150" Source="WelcomeLogo" />
</ContentView>
</Frame>
</Grid>
</ContentPage>
仅使用帧+图像更新图像
当我们使用网格布局时,屏幕分为行和列,这取决于列和行的定义 高度始终取决于行数 宽度也取决于列 在这里,在您的代码中,您将Grid.Row=0设置为frame。它只包含您定义为Row定义的固定高度 假设您使用的是4行,那么单行占据屏幕高度的25%。 列也一样 在代码中,您将负边距设置为“图像视图”,该视图始终保持在行中,而不是帧外
<Frame Grid.Row="0" >
<Image Aspect="AspectFit" Source="WelcomeLogo" VerticalOption="Center" HorizontalOption="Center" />
</Frame>
我不认为框架是这样工作的。这可能有助于向我们展示一个你试图尝试的例子,这样我们可能会给出更好的建议。是的,这是有道理的,但这可以用负填充来解决only@MinaFawzy只需使用Grid.RowSpan并使用AspectFit以任意高度调整图像视图。如果我的答案对您有帮助,请向上投票并愉快地编码:)。