代码之家  ›  专栏  ›  技术社区  ›  D T

如何删除xaml中项目之间的边距?

  •  0
  • D T  · 技术社区  · 7 年前

    这是我的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:local="clr-namespace:TestSalesforce"
                 x:Class="TestSalesforce.MainPage">
    
        <StackLayout Padding="0,0,0,0">
            <!-- Place new controls here -->
            <Label Text="LOGIN" 
               HorizontalOptions="Center" />
            <Label Text="Email:" Margin="0,0,0,0"/>
            <Entry x:Name="txtEmail" Margin="0,0,0,0"/>
            <Label Text="Password:" Margin="0,0,0,0"/>
            <Entry x:Name="txtPassword" Margin="0,0,0,0"/>
            <Button x:Name="btnLogin" Text="Login"/>
            <Button x:Name="btnClose" Text="Close" Clicked="OnClose"/>
        </StackLayout>
    </ContentPage>
    

    这就是结果: enter image description here

    如何删除xaml中项目之间的边距?

    3 回复  |  直到 7 年前
        1
  •  2
  •   Andrew Sellenrick    7 年前

    看起来您的样式已经应用于元素。可能尝试将这些元素的填充设置为0(它们可能不支持填充),或者如果不起作用,则可能需要添加负边距以抵消样式。

        2
  •  2
  •   Csharpest    7 年前

    StackLayout Grid Spacing 我认为默认情况下 StackLayouts 间距 -属性不是 0 2-5 . 尝试设置 Spacing="0"

        3
  •  1
  •   Akash Limbani    7 年前

    尝试以下代码:使用 网格

     <Grid Grid.Row="3">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Controls:Label Grid.Row="0" Font="15" Text="{Binding LabelAddress}"/>
            <StackLayout>
                <Controls:PlaceholderEditor Grid.Row="1" Text="{Binding TextAddress}" VerticalOptions="FillAndExpand" HorizontalOptions="Fill" Margin="0,20,0,0"  Placeholder="Enter Address" PlaceholderColor="{StaticResource LightGray}" AutoSize="TextChanges"/>
            </StackLayout>
        </Grid>
    

    结果是这样的:

    Click Here