1

我在 Xamarin.Forms 中创建了一个 TitleView。该视图适用于 iOS,但在 Android 上它不会填满父视图:

红色区域是 Tabbar 的背景。水色 TitleView 的背景。对我来说,看起来有一些填充或边距?

这是我的标题视图:

    <ContentView xmlns="http://xamarin.com/schemas/2014/forms"
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                 xmlns:ffi="clr-命名空间:FFImageLoading.Svg.Forms;assembly=FFImageLoading.Svg.Forms"
                 xmlns:fft="clr-命名空间:FFImageLoading.Transformations;assembly=FFImageLoading.Transformations"
                 x:Class="App.Views.TitleView"
                 背景颜色="水色"
                 Horizo​​ntalOptions="FillAndExpand"
                 VerticalOptions="FillAndExpand">
        <内容视图.内容>
            <Grid Horizo​​ntalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
                <Image Source="logo.png" HeightRequest="16" VerticalOptions="Center" Horizo​​ntalOptions="Center" ></Image>
                <Grid Horizo​​ntalOptions="End">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="auto"/>
                    </Grid.ColumnDefinitions>
                    <ffi:SvgCachedImage Source="Images/info.svg" HeightRequest="20" Horizo​​ntalOptions="End">
                        <ffi:SvgCachedImage.Transformations>
                            <fft:TintTransformation HexColor="#ffff0000" EnableSolidColor="true"/>
                        </ffi:SvgCachedImage.Transformations>
                        <ffi:SvgCachedImage.GestureRecognizers>
                            <TapGestureRecognizer Tapped="infoIcon_Tapped" NumberOfTapsRequired="1" />
                        </ffi:SvgCachedImage.GestureRecognizers>
                    </ffi:SvgCachedImage>
                </网格>
            </网格>
        </ContentView.Content>
    </内容视图>

这是我的内容视图:

    <TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
                xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                xmlns:local="clr-命名空间:App"
                xmlns:pages="clr-命名空间:App.Pages"
                xmlns:extensions="clr-namespace:App.Code.Extensions"
                xmlns:views="clr-命名空间:App.Views"
                xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core"
                x:Class="App.MainPage"
                android:TabbedPage.ToolbarPlacement="底部">
        <NavigationPage.TitleView>
            <views:TitleView></views:TitleView>
        </NavigationPage.TitleView>
        <TabbedPage.Children>
            ...
        </TabbedPage.Children>
    </TabbedPage>

4

1 回答 1

1

你为什么不尝试这样的事情:

 <ContentView.Content>
        <StackLayout Spacing="0" Orientation="Horizontal"> 
            <Image Source="logo.png" HeightRequest="16" VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand" ></Image>                
                <ffi:SvgCachedImage Source="Images/info.svg" HeightRequest="20" HorizontalOptions="EndAndExpand" VerticalOptions="CenterAndExpand >
                    <ffi:SvgCachedImage.Transformations>
                        <fft:TintTransformation HexColor="#ffff0000" EnableSolidColor="true"/>
                    </ffi:SvgCachedImage.Transformations>
                    <ffi:SvgCachedImage.GestureRecognizers>
                        <TapGestureRecognizer Tapped="infoIcon_Tapped" NumberOfTapsRequired="1" />
                    </ffi:SvgCachedImage.GestureRecognizers>
                </ffi:SvgCachedImage>             
    </ContentView.Content>
于 2018-12-05T13:14:52.687 回答