android - Navigation with drawer and tabs like in Newstand -


i'm trying replicate google newstand app navigation system, can use navigation drawer menu , tabs @ same time, this: enter image description here

i'm trying achieve exact same effect newstand, single color action bar , tabs, , tabs not spanning whole lenght of screen able decompile app, , i've seen source of app uses (series guide) they're quite complex , can't find , figure out , how it's implemented.

i have tried using template android studio has created me navigation drawer , adding tabs no effect

    protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);          mnavigationdrawerfragment = (navigationdrawerfragment)                 getsupportfragmentmanager().findfragmentbyid(r.id.navigation_drawer);         mtitle = gettitle();          // set drawer.         mnavigationdrawerfragment.setup(                 r.id.navigation_drawer,                 (drawerlayout) findviewbyid(r.id.drawer_layout));          actionbar actionbar = getsupportactionbar();         /*         actionbar.setnavigationmode(actionbar.navigation_mode_tabs);         actionbar.setdisplayshowtitleenabled(true);           actionbar.tab tab = actionbar.newtab()                 .settext("artist")                 .settablistener(new tablistener<placeholderfragment>(                         this, "artist", placeholderfragment.class));         actionbar.addtab(tab);          tab = actionbar.newtab()                 .settext("album")                 .settablistener(new tablistener<placeholderfragment>(                         this, "album", placeholderfragment.class));         actionbar.addtab(tab); */          actionbar.sethomebuttonenabled(true);         actionbar.setnavigationmode(actionbar.navigation_mode_tabs);          string[] tabs = { "top rated", "games", "movies" };         // adding tabs         (string tab_name : tabs) {             actionbar.addtab(actionbar.newtab().settext(tab_name)                     .settablistener(new tablistener<placeholderfragment>(                             this, "album", placeholderfragment.class)));         }     } 

so far i've tried using android libraries, don't mind using external onex actionbar sherlock

you're looking google's slidingtablayout. , seriesguide open source, uses pagerslidingtabstrip.

to use google's slidingtablayout, you'll need copy on 2 classes project. classes need are:

an example layout implementing slidingtablayout looks like:

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android"       android:layout_width="match_parent"       android:layout_height="match_parent"       android:orientation="vertical">      <your_path_to.slidingtablayout           android:id="@+id/slidingtabs"           android:layout_width="match_parent"           android:layout_height="wrap_content" />      <android.support.v4.view.viewpager           android:id="@+id/viewpager"           android:layout_width="match_parent"           android:layout_height="0dp"           android:layout_weight="1" />  </linearlayout>  

after inflating layout , initializing slidingtablayout using view.findviewbyid, call slidingtablayout.setviewpager bind viewpager tabs.

check out google's example full project


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -