Xamarin.Forms中TabbedPage上的Android.Views.充气异常



错误:Android.Views.充气异常:'二进制XML文件行#1:二进制XML文件列#1:充气类Android.support.design.widget.TabLayout'时出错

我添加了新的TabbedPage,然后在AppShell.xaml

<ShellContent Title="About" Route="AboutTabbedPage" ContentTemplate="{DataTemplate local:AboutTabbedPage}"  />

但是当我点击";关于";在模拟器中,它抛出错误

Android.Views.InflateException: 'Binary XML file line #1: Binary XML file line #1: Error inflating class android.support.design.widget.TabLayout'

在任何新的TabbedPage上都会引发错误。

TabbedPage的内容如下

<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="myapp.Views.AboutTabbedPage"
Title="{Binding Title}"
xmlns:vm="clr-namespace:myapp.ViewModels"

>
<!--Pages can be added as references or inline-->
<ContentPage Title="Tab 2">
<StackLayout>
<Label Text="Green"  HorizontalTextAlignment="Center" HorizontalOptions="FillAndExpand" Margin="5" />
<BoxView Color="Green" VerticalOptions="FillAndExpand" />
</StackLayout>
</ContentPage>
</TabbedPage>

android项目中的styles.xml如下:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>

我不得不在中更改TabLayout。。。来自的Android\Resources\layout\Tabber.xml项目android.support.design.widget.TabLayoutcom.google.android.material.tabs.TabLayout然后它开始按预期工作。

相关内容

最新更新