title: How to change color of tab selected in tablayout
body: <p>How do I change the color of the selected tab? I would like to each tab to have its own color attribute. So tab 1 selected would be Red. Tab 2 selected would be Blue. Tab 3 selected is Yellow. When not selected they go back to the tab original color.</p>
  
  <p>Currently, I am using a selector to change the background of the selected tab. However, that only allows for one color. I would like to have multiple colors</p>
  
  <p>This is the unselected_tab.xml</p>
  
  <pre><code>&lt;shape xmlns:android="http://schemas.android.com/apk/res/android"
  
      android:shape="rectangle"&gt;
      &lt;solid
          android:color="@color/colorPrimaryDark" /&gt;
  
  &lt;/shape&gt;
  </code></pre>
  
  <p>This is the selected_tab.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;shape xmlns:android="http://schemas.android.com/apk/res/android"
  
      android:shape="rectangle"&gt;
      &lt;solid
          android:color="@color/tabSelectedColor" /&gt;
  
  &lt;/shape&gt;
  </code></pre>
  
  <p>This is the selector I am using </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;selector
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:enterFadeDuration="50"
      android:exitFadeDuration="50" &gt;
  
      &lt;item android:drawable="@drawable/tab_selected"
          android:state_selected="false" /&gt;
      &lt;item android:drawable="@drawable/tab_unselected"
          android:state_selected="true"/&gt;
  &lt;/selector&gt;
  </code></pre>
  
  <p>And I am applying it to the tablayout background</p>
  
  <pre><code>&lt;com.google.android.material.tabs.TabLayout
              android:id="@+id/tablayout"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:background="?attr/colorPrimaryDark"
              android:minHeight="?attr/actionBarSize"
              android:elevation="5dp"
              android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
              app:tabIndicatorColor="@android:color/white"
              app:tabMode="scrollable"
              app:tabMaxWidth="100dp"
              app:tabBackground="@drawable/tab_selector"
              /&gt;
  </code></pre>
  
  <p>Below here are some screen shots of how it looks currently.
  <a href="https://i.stack.imgur.com/RzNLY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RzNLY.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/JwBgH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JwBgH.png" alt="enter image description here"></a></p>
  
  <p>Ideally, I would like for each tab to have its own separate color.</p>
  
  <p>How can accomplish this?</p>
  
  <p>EDIT: IDEALLY I WOULD LIKE TO CHANGE EACH TAB COLOR PROGRAMATICALLY </p>