Android Pagerslidingtabstrip Introduction and use

Source: Internet
Author: User

First look at the effect



GitHub already has this open source project, so we can use it directly, very convenient and practical. I will put resources at the end of the article, can download directly.

How to use

1. Download Zip archive

Download zip file from Pagerslidingtabstrip official website (https://github.com/astuetz/PagerSlidingTabStrip), unzip zip file after successful downloading

2. Import Library and sample project

Import, Android, Existing Android Code into Workspace, Browse, select the Library directory you unzipped, and remember to tick the Copy projects into W Orkset

Android Studiojoin dependent on Build.gradle

dependencies {    compile ' com.astuetz:pagerslidingtabstrip:1.0.1 '}
3. Add the Pagerslidingtabstrip control to your layout, which is usually on top of the Viewpager control

<com.astuetz.pagerslidingtabstrip    android:id= "@+id/tabs"    android:layout_width= "Match_parent    " android:layout_height= "48dip"/>

4. In your OnCreate method (or Oncreateview for a fragment), BindPagerslidingtabstripControl to Viewpager

Initialize Viewpager and add adapter Viewpager pager = (Viewpager) Findviewbyid (R.id.pager); Pager.setadapter (New Testadapter (Getsupportfragmentmanager ())); Bind Pagerslidingtabstrip   pagerslidingtabstrip tabs = (pagerslidingtabstrip) Findviewbyid (R.id.tabs) to Viewpager; Tabs.setviewpager (pager);


5. (optional) If you want to use the Viewpager in yourOnpagechangelistener monitoring method, you should set the following, instead of directly using Viewpager settings

Continue Tabs.setonpagechangelistener from above (Mpagechangelistener);

Personalized Settings

To make your app look like another app on the Play store, you can add these attributes to make your own unique app.

  • pstsIndicatorColorColor of the sliding indicator slider bar
  • pstsUnderlineColorColor of the full-width lines on the bottom of the full width line where the view slider is located
  • pstsDividerColorColor of the dividers between tabs the split line colors of each label
  • pstsIndicatorHeightHeight of the sliding indicator slide bar
  • pstsUnderlineHeightHeight of the full-width line on the bottom of the full width of the view slider
  • pstsDividerPaddingTop and bottom padding of the dividers split line bottom and top fill width
  • pstsTabPaddingLeftRightLeft and right padding of every tab padding width around each tab
  • pstsScrollOffsetScroll offset of the selected tab
  • pstsTabBackgroundBackground drawable of every tab, should be a statelistdrawable the background of each label, should be a statelistdrawable
  • pstsShouldExpandIf set to True, every tab is given the same weight, and default False if set to True, each label is the same control, evenly split the entire screen, and defaults to False
  • pstsTextAllCapsIf true, all tab titles are upper case, default True if True, all tags are uppercase, and true

All attributes have their own getter and setter methods to change them at any time





Android Pagerslidingtabstrip Introduction and use

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.