首页 文章

TabColor未在ThriveGmbH.BottomNavigationBar.XF xamarin.forms中设置

提问于
浏览
0

我在xamarin.forms中使用"BottomNavigationBar"来实现底部Bar . 我根据以下链接"https://github.com/HoussemDellai/BottomBar-Xamarin-Forms"自定义它 . 我没有实现ThriveGmbH.BottomNavigationBar.XF的直接nuget .

版本详细信息xamarin.forms:3.0.482510 BottomNavigationBar:1.4.0.3 Xamarin.Android.Support.Design:25.4.0.2

Question : TabColor is not set according to the sample. default color is white.

代码:

<xf:BottomBarPage xmlns="http://xamarin.com/schemas/2014/forms"
            xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
            x:Class="Inika.Views.BottomBar.BottomBarPages"
            xmlns:pages="clr-namespace:Inika.Views.Category;assembly=Inika"
            xmlns:xf="clr-namespace:Inika.Views.BottomBar;assembly=Inika">
  <!--Pages can be added as references or inline-->
    <pages:Product Title="PRODUCT" Icon="ic_favorites.png" xf:BottomBarPageExtensions.TabColor="#5D4037"/>
    <ContentPage Title="APPLICATION" Icon="ic_nearby.png" xf:BottomBarPageExtensions.TabColor="#7B1FA2"/>
    <ContentPage Title="IMAGES" Icon="ic_restaurants.png" xf:BottomBarPageExtensions.TabColor="#FF5252"/>
</xf:BottomBarPage>

但是xf:BottomBarPageExtensions.TabColor =“#FF5252”未按预期工作

Tabbar.axml

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.TabLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/sliding_tabs"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="?attr/colorPrimary"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:tabIndicatorColor="@android:color/white"
    app:tabGravity="fill"
    app:tabMode="fixed"/>

My custom render is also called perfectly. I can not figure out. In the sample, everything works properly but when I implemented the same thing in my project it is not working.

我应该使用ThriveGmbH.BottomNavigationBar.XF的版本v1.0.3而不是v1.0.2吗?

1 回答

  • 0

    然后,您必须使用FixedMode,并使用Android渲染器中的以下代码将Background或Tab的颜色设置为活动或非活动 .

    _bottomBar.UseFixedMode();
                    _bottomBar.LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);
                    _bottomBar.SetOnTabClickListener(this);
                    _bottomBar.SetTypeFace("SF-UI-Text-Regular.ttf");
                    _bottomBar.SetActiveTabColor("#434A4F");
                    _bottomBar.SetFixedInactiveIconColor("#d0d0d0");
                    _bottomBar.SetBackgroundColor(Android.Graphics.Color.Violet);
    
                    UpdateTabs();
                    UpdateBarBackgroundColor();
                    UpdateBarTextColor();
    

相关问题