Skip to content

A compound pager component bundled with a tablayout to easily create custom sliders

License

Notifications You must be signed in to change notification settings

AZKZero/AndroidCompoundPager

Repository files navigation

Android CompoundPager

A custom pager component to help you easily create sliders with your own layouts and indicators.

Build

API

Importing

  • add maven { url 'https://jitpack.io' } to project level build.gradle file
      allprojects {
          repositories {
              google()
              jcenter()
      
              maven { url 'https://jitpack.io' }
          }
      }
    
  • add implementation 'com.github.AZKZero:AndroidCompoundPager:1.0.0 to module level build.gradle file

Usage

In your layout XML file:

<com.azkzer0.compoundpager.pagercomponent.CompoundPager
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintTop_toTopOf="parent"
        app:viewPagerHeightWrapContent="false"
        app:viewPagerHeight="500dp"
        android:id="@+id/comp"
        app:tabIndicatorLayout="@layout/your_custom_layout" />
  • viewPagerHeightWrapContent (boolean) (Untested) (Default false) To set the pager height as WRAP_CONTENT
  • viewPagerHeight (dimension) (Default 300) (Unused if viewPagerHeightWrapContent is true) To set a fixed pager height
  • tabIndicatorLayout (layout reference) (responds to state_selected)

In your activity of fragment class

        compoundPager.setAdapter(adapter = new CompoundPagerAdapter(getSupportFragmentManager(),fragments));
        compoundPager.setTimeInterval(5000);
  • fragments: An ArrayList to populate the pager
  • setTimeInterval(int milliSeconds): setting value will initiate pager auto-scroll If any items are addded/removed in the ArrayList, notifyDataSetChanged should be called on the adapter, the tab indicators should react accordingly

About

A compound pager component bundled with a tablayout to easily create custom sliders

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages