0

我正在努力解决这个问题。在我的内容页面中,我有一个包含标签和按钮的标题视图。如果我在 android 中执行一切正常,但在 ios 中,按钮从屏幕右侧消失。

编码:

<Shell.TitleView>
    <Grid
        Margin="0,0,0,0"
        RowDefinitions="auto" 
        ColumnDefinitions="auto,*">
        <Label
            Grid.Column="0"
            Text="{Binding Title}"
            TextColor="{StaticResource TextGray}"
            FontSize="Title"
            VerticalTextAlignment="Center"
            VerticalOptions="Center">
        </Label>
        <Grid
            Grid.Column="1"
            BackgroundColor="Green">
            <ImageButton
            Clicked="ShowSearchPage"
            BackgroundColor="red"
            HorizontalOptions="End"
            Source="search"
            ></ImageButton>
        </Grid>
    </Grid>
</Shell.TitleView>

结果在Android这里

在 iOS 中得到结果

4

1 回答 1

0

我试过你的代码,但测试结果有点不同,图标显示不完整,我什至尝试使用 StackLayout而不是outer Gird运气,TitleView占用空间的计算不正确,这是一个潜在的问题,请随意在 github 上提出问题:https ://github.com/xamarin/Xamarin.Forms/issues 。

在此处输入图像描述

而对于临时的解决方法,可以设置Margin在 ImageButton 上,虽然丑但是很有用。

 <ImageButton Margin="0,0,20,0"/>
于 2021-11-12T07:45:31.370 回答