Giter VIP home page Giter VIP logo

wangjun / multiviewpager Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pixplicity/multiviewpager

0.0 1.0 0.0 1.06 MB

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.

License: Apache License 2.0

Java 100.00%

multiviewpager's Introduction

MultiViewPager

Android Arsenal Build Status

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="0dp"
    android:layout_marginTop="16dp"
    android:layout_weight="1"
    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:layout_marginLeft="16dp"
            android:layout_marginRight="16dp"
            android:background="@drawable/bg_page"
            android:scaleType="centerInside"
            android:src="@drawable/im_pixplicity"
            tools:ignore="ContentDescription" />
    </FrameLayout>

</RelativeLayout>

Therefore, the MultiViewPager matches @id/vg_cover:

<com.pixplicity.multiviewpager.MultiViewPager
    android:id="@+id/pager"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_marginTop="16dp"
    android:layout_weight="1"
    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.

multiviewpager's People

Contributors

aegis123 avatar pflammertsma avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.