Git Product home page Git Product logo

customviewpager's Introduction

Custom ViewPager

A Custom ViewPager Library for Android written in Java. There is also available a Kotlin Version

Features:

  • Infinite Pages (from first to last and vice versa)
  • Page Indicators
  • Single Page Supported

Download:

Gradle:

implementation 'com.thisobeystudio.customviewpager:customviewpager:2.0.3'

Implementation into an existing project:

  1. Replace ViewPager to CustomViewPager (Java and xml)
  2. Adapter:
    • Must extends to CustomPagerAdapter
    • Replace getItem(Int) to getItem(CustomIndexHelper)
    • Use CustomIndexHelper.dataPosition for data indexing, do NOT use CustomIndexHelper.pagerPosition
    • Replace getCount() to getRealCount(), do NOT use getCount()
  3. See Customization for more options
  4. Optional, init indicators as follows ViewPager.initIndicators()
  5. Optional, Fragment must extend CustomFragment when using complex views to share data between first and last helper pages.

Demos:

Demos

Indicators Features:

  • Notice! Indicators requires a ConstraintLayout as CustomViewPager parent.

Options:

  • Page Selection.
  • AutoScroll to selected item when needed.
  • Multiple indicators rows
  • Customization.
    • Size.
    • Position. (x4)
    • Height Adjust Modes. (x3)
    • Max items per row.
    • Colors and/or Drawable.

Position:

- POSITION_FLOAT_TOP        // both view's shares top position, so indicators are 'inside' the CustomViewPager
- POSITION_FLOAT_BOTTOM     // both view's shares bottom position, so indicators are 'inside' the CustomViewPager
- POSITION_INCLUDE_TOP      // CustomViewPager's top position will be connected to indicators bottom position 
- POSITION_INCLUDE_BOTTOM   // CustomViewPager's bottom position will be connected to indicators top position

Height Adjust Mode:

- MODE_WRAP_HEIGHT          // from 1 to infinite based on rows count
- MODE_FIXED_HEIGHT         // itemHeight * (margin * 2) * maxVisibleIndicatorRows
- MODE_CLAMPED_HEIGHT       // from 1 to maxVisibleIndicatorRows

Customization:

You can override any of the following resources as desired.

Colors:

<color name="indicatorNormal">YOUR_COLOR</color>
<color name="indicatorPressed">YOUR_COLOR</color>
<color name="indicatorSelected">YOUR_COLOR</color>

Dimens:

<dimen name="indicator_vertical_padding">YOUR_VALUE</dimen>
<dimen name="indicator_horizontal_margin">YOUR_VALUE</dimen>
<dimen name="indicator_item_size">YOUR_VALUE</dimen>
<dimen name="indicator_item_padding">YOUR_VALUE</dimen>

Drawable:

ic_indicator.xml

Contributing:

The best way to submit a patch is to send a pull request.

If you want to add new functionality, please file a new proposal issue first to make sure that it is not in progress already. If you have any questions, feel free to create a question issue.

License:

Copyright 2018 Endika Aguilera.

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.

customviewpager's People

Contributors

endikaaguilera avatar

Stargazers

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