ViewPager that slides vertically.

Overview

Download Android Arsenal

ExpandablePager

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

alt tag #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

You might also like...
Combine ViewPager and Animations to provide a simple way to create applications' guide pages.
Combine ViewPager and Animations to provide a simple way to create applications' guide pages.

WoWoViewPager WoWoViewPager combines ViewPager and Animations to provide a simple way to create applications' guide pages. When users are dragging WoW

An android ViewPager extension allowing infinite scrolling

NO LONGER MAINTAINED LoopingViewPager An android ViewPager extension allowing infinite scrolling. You can use it with "standart" PagerAdapter (inflati

Augment Android's ViewPager with wrap-around functionality.

Infinite View Pager Augment Android's ViewPager with wrap-around functionality. Original StackOverflow question: http://stackoverflow.com/questions/75

[Development stopped in 2014. Unfinished and not stable - not recommended to use.] An easy-to-use ViewPager subclass with parallax background effect for Android apps.

Development stopped in 2014 Not developed since 2014. Unfinished and not stable - not recommended to use. ParallaxViewPager An easy-to-use ViewPager s

Android - A ViewPager page indicator that displays the current page number and (optionally) the page count
Android - A ViewPager page indicator that displays the current page number and (optionally) the page count

NumericPageIndicator A ViewPager page indicator that displays the current page number and (optionally) the page count. It can also display buttons to

Pager (especially for ViewPager) indicator in two styles: circle & fraction.
Pager (especially for ViewPager) indicator in two styles: circle & fraction.

PagerIndicator Pager (especially for ViewPager) indicator in two styles: circle & fraction. Demo circle fraction Dependency implementation 'me.liangfe

Android ViewPager template with cool animation.
Android ViewPager template with cool animation.

glazy-viewpager ViewPager template with cool animation. Preview Dependencies compile 'com.android.support:palette-v7:25.2.0' Usage Refer the implement

ViewPager cards inspired by Duolingo
ViewPager cards inspired by Duolingo

ViewPagerCards ViewPager cards inspired by Duolingo From my blog post: https://rubensousa.github.io/2016/08/viewpagercards This is just a sample proje

Paging indicator widgets compatible with the ViewPager from the Android Support Library and ActionBarSherlock.
Paging indicator widgets compatible with the ViewPager from the Android Support Library and ActionBarSherlock.

Android ViewPagerIndicator Paging indicator widgets that are compatible with the ViewPager from the Android Support Library to improve discoverability

Comments
  • Can't find fragment by tag

    Can't find fragment by tag

    When setting a OnSliderStateChangeListener and using a FragemtnPagerAdapter, getView() is puking because no fragment is being returned by id. Relying on internal API code such as "android:switcher:" + R.id.internal_pager_id + ":" + position is fragile and will break. Is the View object really necessary for the OnSliderStateChangeListener? It seems like position could suffice and maybe just make getPage public instead?

    java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.support.v4.app.Fragment.getView()' on a null object reference
                                                                     at com.telenav.expandablepager.ExpandablePager.getPage(ExpandablePager.java:241)
                                                                     at com.telenav.expandablepager.ExpandablePager.access$200(ExpandablePager.java:46)
                                                                     at com.telenav.expandablepager.ExpandablePager$1.onPageScrolled(ExpandablePager.java:92)
                                                                     at android.support.v4.view.ViewPager.dispatchOnPageScrolled(ViewPager.java:1845)
                                                                     at android.support.v4.view.ViewPager.onPageScrolled(ViewPager.java:1819)
                                                                     at android.support.v4.view.ViewPager.pageScrolled(ViewPager.java:1757)
                                                                     at android.support.v4.view.ViewPager.scrollToItem(ViewPager.java:633)
                                                                     at android.support.v4.view.ViewPager.onLayout(ViewPager.java:1706)
                                                                     at android.view.View.layout(View.java:16636)
                                                                     at android.view.ViewGroup.layout(ViewGroup.java:5437)
                                                                     at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1079)
                                                                     at android.view.View.layout(View.java:16636)
                                                                     at android.view.ViewGroup.layout(ViewGroup.java:5437)
                                                                     at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1079)
                                                                     at android.view.View.layout(View.java:16636)
                                                                     at android.view.ViewGroup.layout(ViewGroup.java:5437)
                                                                     at android.support.v4.view.ViewPager.onLayout(ViewPager.java:1695)
                                                                     at android.view.View.layout(View.java:16636)
                                                                     at android.view.ViewGroup.layout(ViewGroup.java:5437)
                                                                     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
                                                                     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
                                                                     at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
                                                                     at android.view.View.layout(View.java:16636)
                                                                     at android.view.ViewGroup.layout(ViewGroup.java:5437)
                                                                     at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
                                                                     at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
                                                                     at android.view.View.layout(View.java:16636)
                                                                     at android.view.ViewGroup.layout(ViewGroup.java:5437)
                                                                     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
                                                                     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
                                                                     at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
                                                                     at android.view.View.layout(View.java:16636)
                                                                     at android.view.ViewGroup.layout(ViewGroup.java:5437)
                                                                     at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
                                                                     at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
                                                                     at android.view.View.layout(View.java:16636)
                                                                     at android.view.ViewGroup.layout(ViewGroup.java:5437)
                                                                     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
                                                                     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
                                                                     at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
                                                                     at android.view.View.layout(View.java:16636)
                                                                     at android.view.ViewGroup.layout(ViewGroup.java:5437)
                                                                     at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
                                                                     at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
                                                                     at com.android.internal.policy.PhoneWindow$DecorView.onLayout(PhoneWindow.java:2678)
                                                                     at android.view.View.layout(View.java:16636)
                                                                     at android.view.ViewGroup.layout(ViewGroup.java:5437)
                                                                     at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2171)
                                                                     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1931)
                                                                     at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
                                                                     at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)
                                                                     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
                                                                     at android.view.Choreographer.doCallbacks(Choreographer.java:670)
                                                                     at android.view.Choreographer.doFrame(Choreographer.java:606)
                                                                     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
                                                                     at android.os.Handler.handleCallback(Handler.java:739)
                                                                     at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                     at android.os.Looper.loop(Looper.java:148)
                                                                     at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                     at java.lang.reflect.Method.invoke(Native Method)
                                                                    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:72
    
    bug 
    opened by vincentjames501 2
  • Potentially useful additions

    Potentially useful additions

    OnSliderStateChangeListener

    It would be nice to include the page positions like so:

    public interface OnSliderStateChangeListener {
        void onStateChanged(View page,@SlidingContainer.SliderState int state, int position);
        void onPageChanged(View page,@SlidingContainer.SliderState int state, int position);
    }
    

    ExpandablePager

    You can call setCurrentItem(...) but there should be a getCurrentItem() as well.

    ExpandablePagerAdapter

    It would be nice if you could also extend FragmentPagerAdapter. I'd like to use fragments instead of views for this.

    enhancement 
    opened by vincentjames501 1
Owner
Telenav Inc
Telenav Inc
UltraViewPager is an extension for ViewPager to provide multiple features in a single ViewPager.

UltraViewPager 中文文档 ProjectUltraViewPager is a ViewPager extension that encapsulates multiple features, mainly to provide a unified solution for multi

Alibaba 5k Dec 20, 2022
Pixplicity 915 Nov 8, 2022
Don't write a ViewPager Adapter! Hook up your ViewPager to your data model using Android Data Binding Framework. With Kotlin support!

Don't write a ViewPager Adapter! Hook up your ViewPager to your data model using Android Data Binding Framework. Show some ❤️ ?? Sweet and short libra

Rakshak R.Hegde 180 Nov 18, 2022
Persons cards list viewpager - Persons cards list viewpager using kotlin

persons_cards_list_viewpager Дизайн и условие взяты из https://github.com/appKOD

Mironov Ury 1 Mar 1, 2022
Library containing common animations needed for transforming ViewPager scrolling for Android v13+.

ViewPagerTransforms Library containing common animations needed for transforming ViewPager scrolling on Android v13+. This library is a rewrite of the

Ian Thomas 2.5k Dec 31, 2022
Paging indicator widgets compatible with the ViewPager from the Android Support Library and ActionBarSherlock.

Android ViewPagerIndicator Paging indicator widgets that are compatible with the ViewPager from the Android Support Library to improve discoverability

Jake Wharton 10.2k Jan 3, 2023
A custom ViewPager title strip which gives continuous feedback to the user when scrolling

SmartTabLayout A custom ViewPager title strip which gives continuous feedback to the user when scrolling. This library has been added some features an

ogaclejapan 7k Jan 1, 2023
A Material Design ViewPager easy to use library

MaterialViewPager Material Design ViewPager easy to use library Sample And have a look on a sample Youtube Video : Youtube Link Download In your modul

Florent CHAMPIGNY 8.2k Dec 29, 2022
A different beautiful ViewPager, with quick swipe controls

HollyViewPager Usage Add a HollyViewPager in your layout <com.github.florent37.hollyviewpager.HollyViewPager android:id="@+id/hollyViewPager"

Florent CHAMPIGNY 1.1k Dec 9, 2022
An interactive indicator to navigate between the different pages of a ViewPager

Android PagerSlidingTabStrip (default Material Design) This library is not maintained anymore and there will be no further releases. For most of the c

JPARDOGO 2.2k Jan 4, 2023