question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not able to change the tabbar related colors

See original GitHub issue

I’m using 0.6.69-preview version of MBB

Somehow it looks like it ignores for there is no color change in my GUI, please help as I am trying to change the colors of tabbar.

using Android.Content;
using Google.Android.Material.Tabs;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;

[assembly: ExportRenderer(typeof(SomeApp.AppShell), typeof(SomeApp.Droid.MyShellRenderer))]
namespace SomeApp.Droid
{
    public class MyShellRenderer : ShellRenderer
    {
        public MyShellRenderer(Context context) : base(context)
        {
        }

        protected override IShellTabLayoutAppearanceTracker CreateTabLayoutAppearanceTracker(ShellSection shellSection)
        {
            return new MyShellTabLayoutAppearanceTracker(this);
        }
    }

    public class MyShellTabLayoutAppearanceTracker : ShellTabLayoutAppearanceTracker
    {
        public MyShellTabLayoutAppearanceTracker(IShellContext context) : base(context)
        {
        }
        public override void SetAppearance(TabLayout tabLayout, ShellAppearance appearance)
        {
            tabLayout.SetBackgroundColor(Android.Graphics.Color.ParseColor("#002000"));
            
        }

        protected override void SetColors(TabLayout tabLayout, Color foreground, Color background, Color title, Color unselected)
        {
            base.SetColors(tabLayout, Color.Black, Color.White, Color.Black, Color.Gray);

            
            tabLayout.SetSelectedTabIndicatorColor(Color.Red.ToAndroid());
        }
    }

}

AppShell.razor

<Shell BackgroundColor="XF.Color.Black">
        <TabBar Title="Some Title" >
        <Tab Title="Articles" Icon="@(new XF.FileImageSource { File="blog.png" })">
            <ShellContent>
                <SomeApp.WebUI.Pages.ArticlesList />
            </ShellContent>
        </Tab>
       ....
</Tab>
</Shell>

Tabbar.xml

<?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" />

Colors.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <color name="launcher_background">#000000</color>
  <color name="colorPrimary">#000000</color>
  <color name="colorPrimaryDark">#000000</color>
  <color name="colorAccent">#000000</color>
  <color name="splash_background">#000000</color>
</resources>

Styles.xml

<?xml version="1.0" encoding="utf-8" ?>
<resources>

  <style name="MainTheme" parent="MainTheme.Base">
    <item name="android:windowBackground">@drawable/splash_logo</item>
    <item name ="android:colorBackground">#000000</item>
  </style>
  <!-- Base theme applied no matter what API -->
  <style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
    <!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
    <item name="windowNoTitle">true</item>
    <!--We will be using the toolbar so no need to show ActionBar-->
    <item name="windowActionBar">false</item>
    <!-- Set theme colors from https://aka.ms/material-colors -->
    <!-- colorPrimary is used for the default action bar background -->
    <item name="colorPrimary">#000000</item>
    <!-- colorPrimaryDark is used for the status bar -->
    <item name="colorPrimaryDark">#000000</item>
    <!-- colorAccent is used as the default value for colorControlActivated
         which is used to tint widgets -->
    <item name="colorAccent">#000000</item>
    <!-- You can also set colorControlNormal, colorControlActivated
         colorControlHighlight and colorSwitchThumbNormal. -->
    <item name="windowActionModeOverlay">true</item>
    <item name="android:windowBackground">@android:color/black</item>
    <item name="android:datePickerDialogTheme">@style/AppCompatDialogStyle</item>
  </style>

  <style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
    <item name="colorAccent">#000000</item>
  </style>
  
  
  <style name="MyTheme.Base" parent="Theme.AppCompat.Light">
  </style>

  <style name="MyTheme" parent="MyTheme.Base">
  </style>

  <style name="MyTheme.Splash" parent ="Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowBackground">@drawable/logofive</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowActionBar">true</item>
    <item name="android:color">@color/splash_background</item>
  </style>
  
</resources>

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
johnmangamcommented, Sep 20, 2021

I was able to make changes to navbar colors using ShellProperties:

<ContentPage Title="cp title">
    <ShellProperties 
                     BackgroundColor="XF.Color.Red"
                     NavBarIsVisible="true"
                     TitleColor="XF.Color.Yellow" />

Thank you once again @Eilon for your time.

0reactions
johnmangamcommented, Sep 18, 2021

Thank you @Eilon I will try and let you know. Thanks again.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to change the color to tabBar?
I have tried replacing the image with a white image, changing the background color: UITabBar. appearance(). backgroundColor = UIColor.
Read more >
TabBar / Tab colours not working correctly on Windows
TabBarUnselectedColor on a TabBar (or Tab) it does not work. In the example shown, the foreground color should be Green but it is...
Read more >
TabBar: Change color space without tabs : r/FirefoxCSS
I tried several CSS selectors applied to the TabBar, I was able to change the background color of these selectors, but then my...
Read more >
How to control tab bar item color in Swift 4?
I would like to have control over the color of a TabBar item based on some event. I have tried the following: UITabBarItem.appearance()....
Read more >
How can I change tab bar color in ConEmu
Just change your Windows settings (if you can). You right - this color depends on system global Button Background, what can be checked...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found