How to change color of tabbed page indicator in Xamarin.Droid?

后端 未结 3 1034
粉色の甜心
粉色の甜心 2020-12-21 04:22

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.

相关标签:
3条回答
  • 2020-12-21 04:27

    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" />
    
    0 讨论(0)
  • 2020-12-21 04:36

    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" />
    
    0 讨论(0)
  • 2020-12-21 04:43

    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)
    
    0 讨论(0)
提交回复
热议问题