Android - Google Play like tabs

前端 未结 3 1801
遥遥无期
遥遥无期 2020-11-29 19:47

Google has just implemented a new look to their tabs in Google Play.

I know this can be done with ViewPagerIndicator, yet I wouldn\'t like to use another library in

3条回答
  •  情话喂你
    2020-11-29 20:39

    Google finally released their sliding tabs api.

    To use SlidingTabsBasic, you first need to download the zip file from: http://developer.android.com/downloads/samples/SlidingTabsBasic.zip

    1. Include the 2 java source files in the com.example.android.common.view package into your project. You may choose to move them to a suitable package in your project.
    2. To use the component, simply add it to your view hierarchy. Then in your Activity or Fragment, provide the SlidingTabsBasic your viewPager by calling mSlidingTabLayout.setViewPager(mViewPager);

    Example layout from Google:

    
    
        
    
        
    
    
    

    Example code in the onCreate() method of your Activity:

    mSlidingTabLayout = (SlidingTabLayout) view.findViewById(R.id.sliding_tabs);
    mSlidingTabLayout.setViewPager(mViewPager);
    

    For more details, follow the example in the zip file SlidingTabsBasicFragment.java and fragment_sample.xml

提交回复
热议问题