ExpandablePager


Source link: https://github.com/Telenav/ExpandablePager

ExpandablePager

Layout that contains a ViewPager and can slide vertically between 2 states (expanded and collapsed).

#Requirements Android 4.0+ (Ice Cream Sandwich and later) #Setup ###Step 1 Add the following line to the dependencies section of your build.gradle file

compile 'com.telenav.expandablepager:expandablepager:0.2.1'

###Step 2 Extend desired adapter:

  • ExpandablePagerAdapter (don't forget to override instantiateItem)
public class MyAdapter extends ExpandablePagerAdapter<Book> {

 ...

@Override
  public Object instantiateItem(ViewGroup container, int position) {

final ViewGroup rootView = (ViewGroup) LayoutInflater.from(container.getContext()).inflate(R.layout.page, container, false);
 //inflate view

 ...

 return attach(container, rootView, position);
 //don't forget to return the result of attach()
  
}
 
}
  • ExpandableFragmentPagerAdapter
  • ExpandableFragmentStatePagerAdapter

###Step 3 Add ExpandablePager to a layout

<?xml version="1.0" encoding="utf-8"?> RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  android:layout_width="match_parent"
  android:layout_height="match_parent">

<com.telenav.expandablepager.ExpandablePager

android:id="@+id/container"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:layout_gravity="bottom"

android:layout_alignParentBottom="true" /> //pin the pager to the bootom of the screen using layout_gravity or layout_alignParentBottom </RelativeLayout>

###Step 4 Create and pass your adapter to the ExpandablePager

 MyAdapter adapter = new MyAdapter(myData);

  ExpandablePager pager = (ExpandablePager) findViewById(R.id.container);

  pager.setAdapter(adapter);

###Step 5 (optional)

  • Set collapsed height & animation duration via xml
 app:animation_duration="200"
  app:collapsed_height="@dimen/header_height"

or programmatically

 pager.setAnimationDuration(duration);

  pager.setCollapsedHeight((int) getResources().getDimension(R.dimen.header_height));
  • Set display mode (MODE_REGULAR or MODE_FIXED)
 pager.setMode(ExpandablePager.MODE_REGULAR);

#Extras Change pager state (supported states are STATE_COLLAPSED, STATE_EXPANDED, and STATE_HIDDEN)

 pager.setState(ExpandablePager.STATE_COLLAPSED)

Animate pager state change

 pager.animateToState(ExpandablePager.STATE_COLLAPSED)

Set current item

 pager.setCurrentItem(index, false);

Set listeners

 pager.setOnSliderStateChangeListener(new OnSliderStateChangeListener() {

 @Override

public void onStateChanged(View page, int index, int state) {

 ...

}

 @Override

public void onPageChanged(View page, int index, int state) {

 ...

}

  
}
);

 pager.setOnItemSelectedListener(new OnItemSelectedListener() {

@Override

public void onItemSelected(List<?> items, int index) {

 ...

}

  
}
);

#Sample For a more detailed example check the demoapp module.

#License Apache License, Version 2.0

Resources

An Android TagView library. You can customize awesome TagView by using this library.

This is the Android port of an NES emulator written in Go.

Android Library that shows a beautiful and customizable Material designed dialog with header.

An Intellij platform plugin to transforming SVG to android VectorDrawable.

The ultimate product information API, enabling a new breed of product-centric apps.

Persistent SearchView Library in Material Design.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes