[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.

Overview

Development stopped in 2014

Not developed since 2014. Unfinished and not stable - not recommended to use.

ParallaxViewPager

An easy-to-use ViewPager subclass with parallax background.

Setup requires little extra effort, using the ParallaxViewPager is just like using a standard ViewPager, with the same adapter. Of course, there's no silver bullet - the developer has to supply a background tailored to the current needs (eg. the number of items in the adapter and the size of the ViewPager).

  1. Include it in your project as a Gradle dependency:
    dependencies {
        compile 'com.andraskindler.parallaxviewpager:parallaxviewpager:0.3.1'
    }
  1. Create a ParallaxViewPager programmatically or in a layout xml.

  2. Set the background via xml or one of the following methods:

  • setBackgroundResource(int resid)
  • setBackground(Drawable background) or setBackgroundDrawable(Drawable background)
  • setBackground(Bitmap bitmap)
  1. (Optional) Specify how the view should scale the background with the setScaleType(final int scaleType) method. Choose from the following parameters:
  • FIT_HEIGHT means the height of the image is resized to matched the height of the View, also stretching the width to keep the aspect ratio. The non-visible part of the bitmap is divided into equal parts, each of them sliding in at the proper position. This is the default value.
  • FIT_WIDTH means the width of the background image is divided into equal chunks, each taking up the whole width of the screen. This mode is not the usual parallax-effect, as the speed of the background scrolling equals the speed of the views.
  1. (Optional) Set the amount of overlapping with the setOverlapPercentage(final float percentage) method. This is a number between 0 and 1, the smaller it is, the slower is the background scrolling. The default value is 50 percent. This only works with FIT_HEIGHT.

An example, inside the onCreate() of an activity:

    //...
    final ParallaxViewPager parallaxViewPager = new ParallaxViewPager(this);
    parallaxViewPager.setAdapter(new MyPagerAdapter());
    parallaxViewPager.setBackgroundResource(R.drawable.nagy);
    setContentView(parallaxViewPager);
    //...

Other notices

The lowest supported API level is 14 (Ice Cream Sandwich)

By Andras Kindler ([email protected])

License

Copyright 2014 Andras Kindler

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Comments
  • Not supplying XML background cause crashes

    Not supplying XML background cause crashes

    Love the component you've made!

    However, I'm encountering a couple of problems, which I haven't been able to save yet. If I leave out the background of the XML, the app crashes because of an inflation exception. Even if it is specified in the activity. Might be nice to fix this one at a certain time.

    The other thing: The background is not drawn before there was a swipe/motion event. Have you ever experienced this? I think it happened after I made the FragmentStatePagerAdapter so that it could add Fragments dynamically.

    Any of this sounds familiar? I'm still looking to see if I can find anything in the code, if so, I will let you know as well.

    opened by Stingray1984 3
  • Using ParallaxViewPager with Jake Wharton CirclePageIndictor

    Using ParallaxViewPager with Jake Wharton CirclePageIndictor

    While using ParallaxViewPager with CirclePageIndicator of https://github.com/JakeWharton/Android-ViewPagerIndicator, the parallax background is not shown. So what needs to be done to use ParallaxViewPager with CirclePageIndictor . And lastly, great library. Thanks

    opened by leapfrog-santosh 1
  • samsung s4 android 4.4.4 setBackground cannot show ?

    samsung s4 android 4.4.4 setBackground cannot show ?

     hello,Here's my code:
    
     mViewpager.setAdapter(mAdapter);
     mViewpager.setOverlapPercentage(0.99f);
     mViewpager.setBackgroundResource(R.drawable.btn_page_bg);
     mIndicator.setViewPager(mViewpager);
    
     android:id="@+id/viewpager"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
    
    opened by lrain-lv 0
  • Delete addOnPageChangeListener method

    Delete addOnPageChangeListener method

    Hi,

    as I see, there are already a couple of questions, how to make your library work with the popular ViewPagerIndicator library.

    Can you please just delete a ParallaxViewPager#addOnPageChangeListener(OnPageChangeListener listener) method, to make it possible to call the native method from ViewPager#addOnPageChangeListener(OnPageChangeListener listener)? So it becomes possible to use not only 2 listeners. Actually secondOnPageChangeListener field is unnecessary now, it can be removed too.

    thanks in advance & best regards Vitaly

    opened by yital9 0
  • doesn't work properly when page width is below 1f

    doesn't work properly when page width is below 1f

    this is my code: <com.andraskindler.parallaxviewpager.ParallaxViewPager android:id="@+id/pager" android:layout_width="fill_parent" android:layout_height="0dp" android:background="@drawable/background" android:layout_weight="1" android:visibility="gone"/> and the page width: return(0.8f); the problem is when u go to the next page 0.2 background of the page is white

    opened by AmirAliSobhGol 0
  • If not on first page, background image disappears on rotation

    If not on first page, background image disappears on rotation

    If the ViewPager is on the first page, screen rotation works just fine. But if on any of the other pages and I rotate my phone, the background image disappears, resulting, in my case, in a white background.

    I have tried in vain to reset the background resource on onConfigurationChange().

    I am using a resource with the dimensions 1500x1000 as background, set with setBackgroundResource()

    opened by Harteg 1
  • Unexpected layout changes with sticky header and scrolling

    Unexpected layout changes with sticky header and scrolling

    app:viewpager_hideToolbarAndTitle="false"

    Then scroll down just a little bit (halfway)

    Then swipe left/right

    Suddenly the actionbar has background color and tabstrip also.

    Also sometimes when sticky the whole header gets pulled up beyond the status bar, sometimes opposite it gets pulled to almost middle of the screen.

    More an report for the author to look for bugs. Tested on Samsung S6 Edge, Android 5.1

    opened by ramden 0
  • Fixed memory leak

    Fixed memory leak

    When the view pager is detached from a window, it will leak the memory of the bitmap since the bitmap is not being set to null. This fixes that issue and clears the bitmap memory when the view pager is detached.

    opened by mnisbet13 0
  • setCurrentItem makes black background

    setCurrentItem makes black background

    @Override
    public View onCreateView(LayoutInflater inflater,
                             @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_home, container, false);
    
        parallaxHorizontalViewPager = ((ParallaxViewPager) view.findViewById(R.id.parallaxviewpager));
    
        parallaxHorizontalViewPager.setAdapter(new PageHorizontalHomeAdapter(getFragmentManager()));
    
        parallaxHorizontalViewPager.setScaleType(ParallaxViewPager.FIT_WIDTH);
        parallaxHorizontalViewPager.setBackgroundResource(R.drawable.image);
        return view;
    }
    
    
    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        parallaxHorizontalViewPager.setCurrentItem(1, false);
    }
    

    setCurrentItem makes black background. It's like it can calculate the width or something

    opened by josluimg 0
Owner
Andras Kindler
Andras Kindler
Android Parallax-ViewPager

ParallaxViewPager Demo Usage <com.github.ybq.parallaxviewpager.ParallaxViewPager android:id="@+id/viewpager" android:layout_width="ma

ybq 588 Nov 29, 2022
A pager for Android with parallax effect

ParallaxPagerTransformer A pager transformer for Android with parallax effect Installation in your build.gradle file dependencies { // ... com

Javier Gonzalez 654 Dec 29, 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
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
Persons cards list viewpager - Persons cards list viewpager using kotlin

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

Mironov Ury 1 Mar 1, 2022
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
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
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

Manuel Peinado Gallego 253 Nov 16, 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 5, 2023
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

黄伟平 2.7k Dec 30, 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
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

Leszek Mzyk 992 Nov 10, 2022
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

Antony Tran 692 Dec 14, 2022
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

Kannan Anbarasan 251 Nov 29, 2022
Endless full-screen card ViewPager inspired by apple iBook for Android

FullScreenCardViewPager for Android Endless full-screen card ViewPager inspired by apple iBook for Android. ✅ We are open to any new feature request,

Iman Dolatkia 136 Dec 16, 2022
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 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