Recently more busy, long time no update blog. The first day of the national Day did not come home, idle can put before you want to post something to write.
Students who have used the smooth and Fuubo two excellent third-party microblogging clients should have seen their home page UI, such as:
They put the switching tabs indicator on the Actionbar, which saves the space devoted to tabs. We can have more visual space to browse the main microblogging content.
The tab switcher on the Actionbar is a custom component Tabbarview.
Declare a tabbarview and set a viewpaper, add Tabbarview in the Oncreateoptionsmenu menu method to show Actionbar toggle indicator on the right side of tabs
@Override Public BooleanOncreateoptionsmenu (Menu menu) {//inflate the menu; This adds items to the action bar if it is present.getmenuinflater (). Inflate (R.menu.main, menu); View v=(View) Menu.finditem (r.id.action_settings). Getactionview (); Tabbarview=(Tabbarview) V.findviewbyid (R.id.tab_bar); Tabbarview.setstripheight (10); Msectionspageradapter=NewSectionspageradapter (Getfragmentmanager ()); //Set up the Viewpager with the sections adapter.Mviewpager =(Viewpager) Findviewbyid (R.id.pager); Mviewpager.setadapter (Msectionspageradapter); Tabbarview.setviewpager (Mviewpager); return true; }
Add Tabbarview components to the Menu.xml:
<menu xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:tools= "http// Schemas.android.com/tools " tools:context=" Com.example.demo.MainActivity "> <item android:id= "@+id/action_settings" android:orderincategory= "Android" : Showasaction= "Never" android:actionlayout= "@layout/custom_ab"/></menu>
Effect:
Demo:https://github.com/syun0929/tabbarview
android-to merge the indicators of the toggle tabs onto the Actionbar