美文网首页代码片段分享
Xamarin form 去除两控件间的间距

Xamarin form 去除两控件间的间距

作者: 花艺荣 | 来源:发表于2019-07-24 16:23 被阅读0次

    如图两控件之间有间距:


    QQ截图20190724160707.png

    想要效果:


    QQ截图20190724161745.png

    问题代码如下:

    <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>
    

    相关文章

      网友评论

        本文标题:Xamarin form 去除两控件间的间距

        本文链接:https://www.haomeiwen.com/subject/agaxrctx.html