1

I am trying to change background color of tab in tablayout , i have tried several suggested methods on SO ,

but unfortunately they are working only onSwipe tab change , not onClick

Here are some questions i have been following Q1 , Q2

My Attempt:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/tab1_background_selected" android:state_selected="true" />
    <item android:drawable="@drawable/tab1_background_unselected" android:state_selected="false" android:state_focused="false" android:state_pressed="false" />
</selector>
  • Set app:tabBackground="@drawable/tab_bg"

  • In tab_bg.xml my code looks something as given above


Note: i am not using TabHost , i'm just using tabLayout with viewpager , so tabHost answers are not helpful for me

Community
  • 1
  • 1
Zulqurnain Jutt
  • 1,083
  • 3
  • 15
  • 41

0 Answers0