android - How to set the background color of the selected tab in PagerTiltleStrip -


i trying change color of selected tab in pagertitlestrip, able change color of entire strip. not wanted.

how achieve this? can 1 help?

you can pagertitlestrip too.

  1. implement viewpager.onpagechangelistener in main activity
  2. put setonpagechangelistener viewpager

    myviewpager.setonpagechangelistener(this);

  3. then overrride methods onpagescrolled, onpageselected, onpagescrollstatechanged

we need put our code in onpageselected(int position) method if have 5 pages, beforthat need - declare pagertitlestrip in main code.

    pagertitlestrip pagertitlestrip; 
  • and in oncreatemethod

    pagertitlestrip = (pagertitlestrip) findviewbyid(r.id.title); 
  • r.id.title id of pagertitlestrip in main_layout

    if(position==0){     pagertitlestrip.setbackgroundcolor(0xff3d0201); } if(position==1){     pagertitlestrip.setbackgroundcolor(0xff013e10); } if(position==2){     pagertitlestrip.setbackgroundcolor(0xff242f52); } if(position==3){     pagertitlestrip.setbackgroundcolor(0xff60611d); } if(position==4){     pagertitlestrip.setbackgroundcolor(0xff5e2e52); } 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -