繁体   English   中英

Xamarin.Forms TitleView FillAndExpand 不适用于 Android

[英]Xamarin.Forms TitleView FillAndExpand not working with Android

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

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

这是我的标题视图:

<ContentView xmlns="http://xamarin.com/schemas/2014/forms" 
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                 xmlns:ffi="clr-namespace:FFImageLoading.Svg.Forms;assembly=FFImageLoading.Svg.Forms"
                 xmlns:fft="clr-namespace:FFImageLoading.Transformations;assembly=FFImageLoading.Transformations"
                 x:Class="App.Views.TitleView"
                 BackgroundColor="Aqua"
                 HorizontalOptions=" FillAndExpand"
                 VerticalOptions="FillAndExpand">
        <ContentView.Content>
            <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>
                </Grid>
            </Grid>
        </ContentView.Content>
    </ContentView>

这是我的内容视图:

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

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM