How to style Android default ViewPager's bar, created from Android Studio template -


i trying create tabbed activity, , i'm using viewpager (actually, android studio created template, didn't know viewpager was). want style tab-bar below (indicated red "circle"):

enter image description here

i've tried setting styles.xml tried everything, still, nothing applies that. here code:

@override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);      // set action bar.     final actionbar actionbar = getsupportactionbar();     actionbar.setnavigationmode(actionbar.navigation_mode_tabs);      // create adapter return fragment each of 3     // primary sections of activity.     msectionspageradapter = new sectionspageradapter(getsupportfragmentmanager());      // set viewpager sections adapter.     mviewpager = (viewpager) findviewbyid(r.id.pager);     mviewpager.setadapter(msectionspageradapter);      // when swiping between different sections, select corresponding     // tab. can use actionbar.tab#select() if have     // reference tab.     mviewpager.setonpagechangelistener(new viewpager.simpleonpagechangelistener() {         @override         public void onpageselected(int position) {             actionbar.setselectednavigationitem(position);         }     });      // each of sections in app, add tab action bar.     (int = 0; < msectionspageradapter.getcount(); i++) {         // create tab text corresponding page title defined         // adapter. specify activity object, implements         // tablistener interface, callback (listener) when         // tab selected.         actionbar.addtab(                 actionbar.newtab()                         .settext(msectionspageradapter.getpagetitle(i))                         .settablistener(this));     } } 

ironically, generated code (by android studio's latest version) has many deprecated method calls, don't want touch them unless know i'm doing. here layout file (activity_main.xml), again, generated android studio:

<android.support.v4.view.viewpager xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/pager" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="my_app_identifier"/> 

how can change colors of tab bar?

try using onpageselected it's simplest way think. here link.


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -