All Projects → tommybuonomo → Creative Viewpager

tommybuonomo / Creative Viewpager

Licence: apache-2.0
Creative View Pager easy to use in Android

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Creative Viewpager

Openrndr
OPENRNDR. A Kotlin/JVM library for creative coding, real-time and interactive graphics
Stars: ✭ 486 (-32.03%)
Mutual labels:  creative-coding
People You Should Follow On Codepen
People You Should Follow on CodePen
Stars: ✭ 542 (-24.2%)
Mutual labels:  creative-coding
Dungeontemplatelibrary
🌏: Dungeon free resources (terrain & roguelike generation)
Stars: ✭ 595 (-16.78%)
Mutual labels:  creative-coding
Material Viewpagerindicator
Dot-based Android ViewPager indicator with Material Design animations.
Stars: ✭ 511 (-28.53%)
Mutual labels:  viewpager
Awesome Glsl
🎇 Compilation of the best resources to learn programming OpenGL Shaders
Stars: ✭ 530 (-25.87%)
Mutual labels:  creative-coding
Snaptablayout
Android library for fluid tablayout animation as seen on Snapchat.
Stars: ✭ 547 (-23.5%)
Mutual labels:  viewpager
Banner Slider
Banner slider is an easy to use library for implement image sliders in android apps.
Stars: ✭ 482 (-32.59%)
Mutual labels:  viewpager
Gallerylayoutmanager
New way to implements ViewPager/Gallery in Android with RecycleView
Stars: ✭ 684 (-4.34%)
Mutual labels:  viewpager
Bubbletab
Put some bubble in your tabs and give your apps a supa fresh style !
Stars: ✭ 537 (-24.9%)
Mutual labels:  viewpager
Inkpageindicator
InkPageIndicator created by @nickbutcher for Plaid https://github.com/nickbutcher/plaid and backported by me for API 14+ (4.0+)
Stars: ✭ 589 (-17.62%)
Mutual labels:  viewpager
Banner
轮播图控件,支持自定义布局,支持两端缩进,类似卡片,支持无限循环和多种主题,可以灵活设置轮播样式、动画、轮播和切换时间、位置、图片加载框架等!
Stars: ✭ 512 (-28.39%)
Mutual labels:  viewpager
Glisp
A Lisp-based Design Tool Bridging Graphic Design and Computational Arts
Stars: ✭ 519 (-27.41%)
Mutual labels:  creative-coding
Ultraviewpager
UltraViewPager is an extension for ViewPager to provide multiple features in a single ViewPager.
Stars: ✭ 5,030 (+603.5%)
Mutual labels:  viewpager
Dsltablayout
♥️ Android界最万能的TabLayout(不仅仅是TabLayout), 支持任意类型的item, 支持Drawable类型的指示器,智能开启滚动,支持横竖向布局等
Stars: ✭ 489 (-31.61%)
Mutual labels:  viewpager
Discretescrollview
A scrollable list of items that centers the current element and provides easy-to-use APIs for cool item animations.
Stars: ✭ 5,533 (+673.85%)
Mutual labels:  viewpager
Pageindicatorview
An page indicator for Android ViewPager
Stars: ✭ 4,498 (+529.09%)
Mutual labels:  viewpager
Android Viewpager Transformers
A collection of view pager transformers
Stars: ✭ 546 (-23.64%)
Mutual labels:  viewpager
Easyflipviewpager
📖 The library for creating book and card flip animations in ViewPager in Android
Stars: ✭ 698 (-2.38%)
Mutual labels:  viewpager
Infinitecycleviewpager
Infinite cycle ViewPager with two-way orientation and interactive effect.
Stars: ✭ 5,720 (+700%)
Mutual labels:  viewpager
Litepager
LitePager,一个轻量级的ViewPager,仿新版网易云歌单广场
Stars: ✭ 563 (-21.26%)
Mutual labels:  viewpager

Creative View Pager

Creative View Pager easy to use ! This view pager library combines a header list which is scrolling automatically in coordination with the page contents.

CreativeViewPager

Download

dependencies {
    implementation 'com.tbuonomo:creative-viewpager:1.0.1'
}

Usage

In your XML layout

Add CreativeViewPager in your activity's layout

<com.tbuonomo.creativeviewpager.CreativeViewPager
    android:id="@+id/creativeViewPagerView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:contentHorizontalPadding="32dp"
    app:contentMargin="8dp"
    app:imagesMargin="8dp"
    app:imagesSize="92dp"
    />

You will see a fake preview in Android Studio of the creative view.

Custom XML Attributes

Attribute Description
contentHorizontalPadding The start and end padding in dp of the content pages relative to the parent layout (by default 32dp)
contentItemMargin Margin in dp of each content item (by default 8dp)
headerItemMargin Margin in dp of each header item (by default 8dp)
headerItemSize The size in dp of the header items (by default 92dp)

Adapter

Create your own adapter extending CreativeViewAdapter

class NatureCreativePagerAdapter(val context: Context) : CreativePagerAdapter

By default, you have to override the 3 methods instantiateHeaderItem, instantiateContentItem and getCount.

    override fun instantiateHeaderItem(inflater: LayoutInflater, container: ViewGroup, position: Int): View {
    // Inflate page layout
    val headerRoot = inflater.inflate(R.layout.item_creative_content_nature, container, false)

    // Bind the views
    val title: TextView = headerRoot.findViewById(R.id.itemCreativeNatureTitle)
    val image: ImageView = headerRoot.findViewById(R.id.itemCreativeNatureImage)

    title.text = context.getString(R.string.item_nature_title, position)
    image.setImageDrawable(context.getDrawable(NatureItem.values()[position].natureDrawable))

    return headerRoot
  }

  override fun instantiateContentItem(inflater: LayoutInflater, container: ViewGroup, position: Int): View {
    // Inflate the header view layout
    val contentRoot = inflater.inflate(R.layout.item_creative_header_profile, container,
            false)

    // Bind the views
    val imageView = contentRoot.findViewById<ImageView>(R.id.itemCreativeImage)

    imageView.setImageDrawable(ContextCompat.getDrawable(context, NatureItem.values()[position].userDrawable))
    return contentRoot
  }

  override fun getCount(): Int {
    return NatureItem.values().size
  }

If you want to have the cool colored background effect when you're sliding the view pager, you have to override the two methods and provide the bitmap used for specific position.

  override fun isUpdatingBackgroundColor(): Boolean {
    return true
  }

  override fun requestBitmapAtPosition(position: Int): Bitmap? {
    // Return the bitmap used for the position
    return BitmapFactory.decodeResource(context.resources,
            NatureItem.values()[position].natureDrawable)
  }

In your Activity / Fragment

Finally, set your adapter to the CreativeViewPager in your activity or fragment.

creativeViewPagerView.setCreativeViewPagerAdapter(NatureCreativePagerAdapter(activity))

Don't forget to star the project if you like it! star == heart

Changelog

1.0.1

  • Rename class CreativeViewPagerView to CreativeViewPager
  • Rename class CreativeViewAdapter to CreativePagerAdapter
  • Rename attribute imagesMargin to headerItemMargin
  • Rename attribute imagesSize to headerItemSize
  • Rename attribute contentMargin to contentItemMargin
  • Add the setCurrentItem(position: Int) to CreativeViewPager

Icons designed by Freepics from Flaticon

License

Copyright 2018 Tommy Buonomo

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.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].