我在 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" 背景颜色="水色" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"> <内容视图.内容> <Grid HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"> <Image Source="logo.png" HeightRequest="16" VerticalOptions="Center" HorizontalOptions="Center" ></Image> <Grid HorizontalOptions="End"> <Grid.ColumnDefinitions> <ColumnDefinition Width="auto"/> </Grid.ColumnDefinitions> <ffi:SvgCachedImage Source="Images/info.svg" HeightRequest="20" HorizontalOptions="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>