首页 文章

如何在Android的xamarin.forms中设置所选标签的背景颜色?

提问于
浏览
-3

I am working in xamarin.forms. 我在android中实现了底部标签页,如下面的代码

<TabbedPage 
                xmlns="http://xamarin.com/schemas/2014/forms"
                xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                x:Class="Inika.Views.BottomBar.BottomBarPages"
                xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core"
                BarBackgroundColor="White"
                android:TabbedPage.ToolbarPlacement="Bottom"
                android:TabbedPage.BarItemColor="#A9A9A9"
                android:TabbedPage.BarSelectedItemColor="Black">
</TabbedPage>

I am using new feature of xamarin.form 3.1 as below link

https://blog.xamarin.com/xamarin-forms-3-1-improvments/

根据我目前的代码,我的输出如下图所示

but I want to set background color of selected tab. "BarBackgroundColor" property set the color in whole Bar. I did not found any property who set the color in only selected tab.

我需要像这样的输出

Please suggest work around through custom render or any but I don't want to use any custom plugin.

1 回答

  • 0

    这个问题已经在SO上回答了 . 不过请尝试以下方法 .

    如果您使用的是FormsAppCompatActivity,则可以使用

    app:tabIndicatorColor="#FF3300" <!-- Set indicator color here, sets it to red-->
    

    EDIT

    您需要创建自定义渲染器 .

    检查github上的this示例 .

相关问题