Android custom tab
First, let's take a look at the layout file of the implementation tab.
The first FrameLayout is the container of the tab content.
The following TabView is a tab container.
Then look at the Activity:
Import sunger. widget. tabView; import sunger. widget. tabView. onTabItemClick; import android. OS. bundle; import android. support. v4.app. fragmentActivity; import android. support. v4.app. fragmentTransaction; import android. view. window; import com. sunger. tab_wechat.R; public class MainActivity extends FragmentActivity implements OnTabItemClick {private String [] mTitle = {, Address Book, found, I}; private int [] mIconSelect = {R. drawable. al _, R. drawable. al8, R. drawable. alb, R. drawable. ald}; private int [] mIconNormal = {R. drawable. ala, R. drawable. al9, R. drawable. c, R. drawable. ale}; @ Overrideprotected void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); requestWindowFeature (Window. FEATURE_NO_TITLE); setContentView (R. layout. activity_main); TabView tabView = (TabView) findViewById (R. id. id_tab); // tabView. setmPadding (7); // tabView. setmTextSize (12); // tabView. setmTextColorSelect (0xff45c01a); // tabView. setmTextColorNormal (0xff777777); // tabView. setBackgroundColor (Color. WHITE); tabView. setTitles (mTitle); tabView. setIconNormalIds (mIconNormal); tabView. setIconSeletedIds (mIconSelect); tabView. setOnTabItemClick (this); tabView. build (); tabView. setCurrentItem (0); setCurrentItem (1) ;}@ Overridepublic void onClick (int position) {// here you can set refresh or click the current tab to do not operate setCurrentItem (position );} public void setCurrentItem (int position) {FragmentTransaction transaction = getSupportFragmentManager (). beginTransaction (); transaction. replace (R. id. holder, new WeChatFragment (); transaction. commit ();}}
The UI effect is the same as that of the tab, but it cannot slide left or right. I will not lie to you if I study much.