我目前正試圖為我的TabbedPage使用一個自定義渲染器。
實際上,我想使用該渲染器來改變標簽的字體。不幸的是,當我使用renderer時,Tabbar是不可見的。如果不使用renderer,Tabbar就會顯示。
我是否忘記了什么?
我的頁面:
。<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"/span>
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"/span>
xmlns:d="http://xamarin.com/schemas/2014/forms/design"/span>
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"/span>
mc:Ignorable="d"。
xmlns:views="clr-namespace:***.Views"/span>
x:Class="***.Views.MainPage"/span>
xmlns:utils="clr-namespace:***.Utils"。
BarBackgroundColor="Black"/span> BarTextColor="White"/span>
xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core"
android:TabbedPage.ToolbarPlacement="Bottom"。
android:TabbedPage.BarTextColor="White"/span>
android:TabbedPage.BarItemColor="Gray"/span>
android:TabbedPage.BarSelectedItemColor="White""False"。
CurrentPageChanged="changeTab"。
x:Name="mainTabbedView">
<TabbedPage.Children>
<NavigationPage Title="1" HeightRequest="20">
<NavigationPage.Icon>
<OnPlatform x:TypeArguments="FileImageSource" >
<On Platform="iOS" Value="pic1"/>
<On Platform="Android" Value="pic1"/>
</OnPlatform>
</NavigationPage.Icon>
<x:Arguments>
<views:NewPage />
</x:Arguments>
</NavigationPage>
<NavigationPage Title="2"/span>>
<NavigationPage.Icon>
<OnPlatform x:TypeArguments="FileImageSource">
<On Platform="iOS" Value="pic2"/>
<On Platform="Android" Value="pic2"/>
</OnPlatform>
</NavigationPage.Icon>
<x:Arguments>
<views:OtherPage />
</x:Arguments>
</NavigationPage>
<NavigationPage Title="3"/span>>
<NavigationPage.Icon>
<OnPlatform x:TypeArguments="FileImageSource">
<On Platform="iOS" Value="pic3"/>
<On Platform="Android" Value="pic3"/>
</OnPlatform>
</NavigationPage.Icon>
<x:Arguments>
<views:LastPage />
</x:Arguments>
</NavigationPage>
</TabbedPage.Children>
和渲染器:
using Xamarin.Forms.Platform.Android。 using ***.Droid; using Android.Content; [] namespace ***.Droid[/span>] { class CustomTabbedPageRenderer : TabbedRendererpublic CustomTabbedPageRenderer(Context context) 。base(context)。 { } }uj5u.com熱心網友回復:
我希望在所有的問題都解決之后,如果沒有的話:
我希望在所有的問題都解決之后,你的問題得到解決。
解決方案
在你的渲染器中,在Android專案中,你必須從TabbedPageRenderer繼承,而不是從TabbedRenderer,如下所示
...
public class CustomTabbedPageRenderer : TabbedPageRenderer
{
public CustomTabbedPageRenderer(Context context) : base(context)。
{
}
}
...
注釋
一個類似的問題可以在這里找到。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/317274.html
標籤:
