1

I have list view and each list item holds different color. On click of any list item, I navigate to an activity whose action bar holds some tabs. Now I have to set that color which came from item click as tab indicator color of selected tab. I tried the below link but no luck

Is it possible to change actionbar tab indicator programmatically

Community
  • 1
  • 1
kishore
  • 41
  • 5

1 Answers1

1

you can change focus of selected tab

<!-- Non focused states -->
<item android:state_focused="false" android:state_selected="false"
      android:state_pressed="false"
      android:drawable="@drawable/tab_unselected" />
<item android:state_focused="false" android:state_selected="true"
      android:state_pressed="false"
      android:drawable="@drawable/tab_selected" />

<!-- Focused states (such as when focused with a d-pad or mouse hover) -->
<item android:state_focused="true" android:state_selected="false"
      android:state_pressed="false"
      android:drawable="@drawable/tab_unselected_focused" />
<item android:state_focused="true" android:state_selected="true"
      android:state_pressed="false"
      android:drawable="@drawable/tab_selected_focused" />
<!-- Non focused states -->
<item android:state_focused="false" android:state_selected="false"
      android:state_pressed="true"
      android:drawable="@drawable/tab_unselected_pressed" />
<item android:state_focused="false" android:state_selected="true"
    android:state_pressed="true"
    android:drawable="@drawable/tab_selected_pressed" />

<!-- Focused states (such as when focused with a d-pad or mouse hover) -->
<item android:state_focused="true" android:state_selected="false"
      android:state_pressed="true"
      android:drawable="@drawable/tab_unselected_pressed" />
<item android:state_focused="true" android:state_selected="true"
      android:state_pressed="true"
      android:drawable="@drawable/tab_selected_pressed" />

For more details go through this

Ankit Kumar
  • 3,663
  • 2
  • 26
  • 38