Xamarin form 去除两控件间的间距
2019-07-24 本文已影响0人
花艺荣
如图两控件之间有间距:

想要效果:

问题代码如下:
<StackLayout Orientation="Vertical" BackgroundColor="LightSeaGreen" VerticalOptions="Center" HorizontalOptions="Start" Padding="15" >
<StackLayout.GestureRecognizers>
<TapGestureRecognizer NumberOfTapsRequired="1" Tapped="Button_OnClicked_toSininorsignout"/>
</StackLayout.GestureRecognizers>
<Image Source="{local:ImageResource CameraFTP.Timelapse.Shared.images.login.png}" HeightRequest="20" WidthRequest="20" VerticalOptions="Center" HorizontalOptions="Center" BackgroundColor="Black"></Image>
<Label Text="{StaticResource Mainpage_logon}" TextColor="{StaticResource textColorWhite}" FontSize="12" VerticalOptions="Start" HorizontalOptions="Center" BackgroundColor="Blue"></Label>
</StackLayout>
如图黑色和深蓝控件间有间距,怎么调都去不掉,搞了好久,改进代码如下,仅仅在第一行里加了Spacing="0":
<StackLayout Orientation="Vertical" BackgroundColor="LightSeaGreen" VerticalOptions="Center" HorizontalOptions="Start" Padding="15" Spacing="0">
<StackLayout.GestureRecognizers>
<TapGestureRecognizer NumberOfTapsRequired="1" Tapped="Button_OnClicked_toSininorsignout"/>
</StackLayout.GestureRecognizers>
<Image Source="{local:ImageResource CameraFTP.Timelapse.Shared.images.login.png}" HeightRequest="20" WidthRequest="20" VerticalOptions="Center" HorizontalOptions="Center" BackgroundColor="Black"></Image>
<Label Text="{StaticResource Mainpage_logon}" TextColor="{StaticResource textColorWhite}" FontSize="12" VerticalOptions="Start" HorizontalOptions="Center" BackgroundColor="Blue"></Label>
</StackLayout>