I\'m building an application with Xamarin.Forms and a Portable Class Library. I have a tabbed page. I want to change the color of the tabbed page indicator.
If you are using AppCompat in your Android platform project, in your TabLayout axml file use the tabIndicatorColor property to do this:
<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"
....
app:tabIndicatorColor="#123456" />
If you are using the FormsAppCompatActivity
(Material Design), then all you have to do is open the Tabbar.axml
file in the droid project's Resources folder and change the color set for app:tabIndicatorColor
. For example,
<?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="#FF3300" <!-- Set indicator color here, sets it to red-->
app:tabGravity="fill"
app:tabMode="fixed" />
In the mainview.xaml.cs
, inside public MainView()
:
On<Xamarin.Forms.PlatformConfiguration.Android>().SetBarSelectedItemColor(enter color here)
On<Xamarin.Forms.PlatformConfiguration.Android>().SetBarItemColor(enter color here)