Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xamarin 如何删除xaml中项目之间的边距?_Xamarin_Xamarin.forms - Fatal编程技术网

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

Xamarin 如何删除xaml中项目之间的边距?,xamarin,xamarin.forms,Xamarin,Xamarin.forms,这是我的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" xmln

这是我的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>

我尝试使用Margin=“0,0,0,0”,但不正常: 这是一个结果:


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

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

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

尝试以下代码:使用网格格式

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

结果如下:


尝试以下代码:使用网格格式

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

结果如下:


堆栈布局
网格
具有
间距
-属性。间距描述布局中每个子元素之间的间距。 我认为默认情况下,
StackLayouts
间距
-属性不是
0
,而是
2-5
附近的内容。
尝试在stacklayout上设置
Spacing=“0”

stacklayout
Grid
具有
Spacing
-属性。间距描述布局中每个子元素之间的间距。 我认为默认情况下,
StackLayouts
间距
-属性不是
0
,而是
2-5
附近的内容。
尝试在stacklayout上设置
Spacing=“0”

您的意思是什么?如果您想让标签和条目靠得更近,请尝试指定标签的高度要求。您指的是什么边距?如果您想让标签和条目靠得更近,请尝试指定标签的高度请求。谢谢,但这并没有真正的帮助。仍然可能存在从父控件继承的样式,或者由基样式本身继承的样式。负保证金能解决你的问题吗?Margin=“0,-20,0,0”谢谢,使用Margin=“0,-20,0,0”,android是可以的,但是使用UWP:Entry将覆盖到label。添加特定于平台的Margin,就像您可以为不同的平台使用不同的Margin一样。谢谢,但这并没有真正的帮助。仍然可能存在从父控件继承的样式,或者由基样式本身继承的样式。负保证金能解决你的问题吗?Margin=“0,-20,0,0”谢谢,使用Margin=“0,-20,0,0”,android是可以的,但是使用UWP:Entry将覆盖到label。添加特定于平台的Margin,就像您可以为不同平台使用不同的Margin一样。