Developing a Xamarin app, with Xamarin Forms 5, and using Shell for navigation.
Is it possible to change the color of the icon, to the same color as the text underneath it, upon selecting a tab? The icons are material design fonts.
I have tried to use TabBarTitleColor
, which changes the text color for a selected tab.
Setting the icon color works fine for TabBarUnselectedColor
(can be seen by the green icons in the second picture). But I can't make the icon change color when it is selected.
<Shell.Resources>
<ResourceDictionary>
<Style x:Key="BaseStyle" TargetType="Element">
<Setter Property="Shell.TabBarBackgroundColor"
Value="White" />
<Setter Property="Shell.TabBarForegroundColor"
Value="White" />
<Setter Property="Shell.TabBarUnselectedColor"
Value="Green" />
<Setter Property="Shell.TabBarTitleColor"
Value="Gold" />
</Style>
<Style TargetType="TabBar"
BasedOn="{StaticResource BaseStyle}">
</Style>
</ResourceDictionary>
</Shell.Resources>
<TabBar>
<Tab Title="Exchange" Route="exchange">
<Tab.Icon>
<FontImageSource FontFamily="{StaticResource MaterialFontFamily}" Glyph="{x:Static helpers:IconFont.Earth}" Size="24"/>
</Tab.Icon>
<ShellContent ContentTemplate="{DataTemplate views:ExchangeBasePage}" Route="exchangeBase" />
</Tab>
<Tab Title="Meet" Route="meet">
<Tab.Icon >
<FontImageSource FontFamily="{StaticResource MaterialFontFamily}" Glyph="{x:Static helpers:IconFont.AccountMultipleOutline}" Size="24"/>
</Tab.Icon>
<ShellContent ContentTemplate="{DataTemplate views:MembersListPage}" Route="members" />
</Tab>
</TabBar>
UPDATE
I tried using Font Awesome Icons, but am getting funny characters instead of icons, and they are not changing colour either.
Added Font Awesome otf files to shared resource, marked the build action as Embedded Resource.
In AssemblyInfo:
[assembly: ExportFont("Font-Awesome-5-Brands-Regular-400.otf", Alias = "FontAwesome")]
[assembly: ExportFont("Font-Awesome-5-Free-Regular-400.otf", Alias = "FontAwesome2")]
[assembly: ExportFont("Font-Awesome-5-Free-Solid-900.otf", Alias = "FontAwesome3")]
<TabBar >
<Tab Title="Share" Route="exchange" >
<Tab.Icon>
<FontImageSource FontFamily="Font-Awesome-5-Free-Solid-900.otf" Glyph="" Size="24"/>
</Tab.Icon>
<ShellContent ContentTemplate="{DataTemplate views:ExchangeBasePage}" Route="exchangeBase" />
</Tab>
UPDATE 2
Tried chaning FontFamily
to the three different aliases (e.g. FontAwesome3), same problem.
Tried to see if it was an issue with the TabBar Tab.Icon
by putting the glyph in a Label as text on a normal page, but it resulted in the same character.
<Label Text="" FontFamily="FontAwesome2" FontSize="Header" TextColor="White"/>
Glyph as text in label on normal page
Awesome Font Icon - Showing up as a funny character instead of icon