• Stars
    star
    908
  • Rank 48,775 (Top 1.0 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created over 9 years ago
  • Updated almost 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The MultiViewPager is an extension of the support-v4 library's ViewPager that allows the pages to be wider or narrower than the ViewPager itself. It takes care of aligning the pages next to each other, and always keeping the selected page centered.

MultiViewPager

Android Arsenal Build Status

UPDATE: This behavior is now included in the RecyclerView for support lib 24.2.0 and later. Please look at using LinearSnapHelper.

The MultiViewPager is an extension of the support-v4 library's ViewPager that allows the pages to be wider or narrower than the ViewPager itself. It takes care of aligning the pages next to each other, and always keeping the selected page centered.

Sample app

Sample

Simply add the MultiViewPager into your layout:

<com.pixplicity.multiviewpager.MultiViewPager
    android:id="@+id/pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:matchChildWidth="@+id/child_view_to_match" />

Be sure to declare the app namespace:
xmlns:app="http://schemas.android.com/apk/res-auto"

Take note of the custom attribute matchChildWidth. This attribute should match an ID in the ViewPager's first child view. In the sample project, the layout of the pages is:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="${relativePackage}.${activityClass}" >

    <FrameLayout
        android:id="@+id/vg_cover"
        android:layout_width="200dp"
        android:layout_height="match_parent"
        android:layout_centerInParent="true" >

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:padding="16dp"
            android:background="@drawable/bg_page"
            android:scaleType="centerInside"
            android:src="@drawable/im_pixplicity"
            tools:ignore="ContentDescription" />
            
    </FrameLayout>

</RelativeLayout>

The child view with ID @id/vg_cover will determine the width of the page. In this example, the width would be 200dp. In order to get this hooked up, we provide MultiViewPager with the reference to the child, @id/vg_cover:

<com.pixplicity.multiviewpager.MultiViewPager
    android:id="@+id/pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:matchChildWidth="@+id/vg_cover" />

In this way, it knows to size the pages according to the dimension of that View or ViewGroup.

Download

Download the latest AAR or grab via Maven:

<dependency>
  <groupId>com.pixplicity.multiviewpager</groupId>
  <artifactId>library</artifactId>
  <version>1.0</version>
  <type>aar</type>
</dependency>

or Gradle:

compile 'com.pixplicity.multiviewpager:library:1.0'

License

Licensed under the Apache license.

More Repositories

1

HtmlCompat

Compatibility library for Android's Html class. [DEPRECATED]
Java
558
star
2

EasyPrefs

A small library containing a wrapper/helper for the Shared Preferences of android.
Java
419
star
3

letterpress

Custom fonts without writing code.
Java
135
star
4

humpty-dumpty-android

Simple file dump utility for Android
Shell
104
star
5

gene-rate

Generate a better rating for your Android app
Java
67
star
6

android-custom-components

Custom Components for Android
Java
21
star
7

Proguard-rules

Proguard rules for commonly used libraries
19
star
8

sync-demo

Sync Demo
Java
16
star
9

android-bluetooth-demo

This project demonstrates communicating with a bluetooth device in an Android app.
Java
16
star
10

PoorIntentions

Illustrates invalid back stacks on Android and offers a resolution
Kotlin
11
star
11

adb-control

ADB Control for Root app
Java
6
star
12

HaldCLUT

C/C++ generator for Hald Color Lookup Tables
C
4
star
13

castdemo

Google Cast Demo
Java
4
star
14

ChoiceGridView

Variant of Android's GridView that has improved handling for multiselection.
Java
3
star
15

StandardSmashdown

The official Standard Rules for Smashdown Ping-Pong
3
star
16

gimbal-proximity

Fork and improvement of Gimbal Proximity SDK sample app
Java
3
star
17

flutter_animation_motion

Companion app for my "Animation and motion in Flutter" presentation, showcasing what the framework has to offer to developers for creating simple and yet beautiful animations.
Dart
3
star
18

multi-window-demo

Demo of Android N's Multi-Window mode
Java
2
star
19

weardemo

Java
2
star
20

overlay-android-bug

Demo of a bug in Android 7.1.2 (Nougat) on a Nexus 6P
Java
2
star
21

animation-demo

Java
1
star
22

nougat-photo

A very basic no-frills implementation of using the default camera to return a photo, compatible with Android Nougat.
Java
1
star
23

PriorityAlert

Java
1
star
24

HeadphoneData

Java
1
star
25

resource-converter

Java
1
star