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.
- implement viewpager.onpagechangelistener in main activity
put setonpagechangelistener viewpager
myviewpager.setonpagechangelistener(this);
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
Post a Comment