首页 > 解决方案 > 汉堡图标和搜索栏之间的空白来自哪里?

问题描述

如何让 SearchBar 立即出现在汉堡包图标的右侧(请参见图片),白色空间来自哪里?我找不到它。

iv 将 NavigationPage 中的 stackLayout 和 SearchBar 设置为 `Horizo​​ntalOptions="StartAndExpand" VerticalOptions="StartAndExpand"

是来自 burgerIcon 按钮的填充。我如何检查,我在代码中也找不到它?

感谢您的任何回复

 <?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"x:Class="WineShop.Views.Products">
    <NavigationPage.TitleView>
        <StackLayout HorizontalOptions="StartAndExpand" VerticalOptions="StartAndExpand" Orientation="Horizontal">
            <SearchBar x:Name="SearchBar" TextChanged="SearchBar_TextChanged" HorizontalOptions="StartAndExpand" Placeholder="Search..." PlaceholderColor="Gray" TextColor="White" VerticalOptions="StartAndExpand"/>
        </StackLayout>
    </NavigationPage.TitleView>
    <ContentPage.ToolbarItems>
        <ToolbarItem Name="shoppingCartImg" Icon="shoppingCartImg.png" Priority="0" Order="Primary" Activated="ShoppingCartClicked"/>
        <ToolbarItem Text="{Binding NoItemsInShoppingCart}" Priority="0" Order="Primary" Activated="ShoppingCartClicked"/>
    </ContentPage.ToolbarItems>
    <ContentPage.Content>
        <Grid>

在此处输入图像描述

标签: xamlxamarinxamarin.formssearchbar

解决方案


尝试将以下行添加到您的Toolbar.xml

app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
app:contentInsetStartWithNavigation="0dp"

推荐阅读