• Stars
    star
    632
  • Rank 71,124 (Top 2 %)
  • Language
    Kotlin
  • License
    Apache License 2.0
  • Created over 3 years ago
  • Updated almost 2 years ago

Reviews

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

Repository Details

Carousel Recyclerview let's you create carousel layout with the power of recyclerview by creating custom layout manager.

Carousel Recyclerview

Create carousel effect in recyclerview with the CarouselRecyclerview in a simple way.


Build Status License License License AndroidWeekly


Layout manager

Including in your project

Maven Central with version prefix filter CarouselRecyclerview

Gradle

Add below codes to your root build.gradle file (not your module build.gradle file).

allprojects {
    repositories {
          mavenCentral()
    }
}

And add a dependency code to your module's build.gradle file.

dependencies {
   implementation 'com.github.sparrow007:carouselrecyclerview:1.2.6'
}

Usage

Basic Example for Kotlin

Here is a basic example of implementing carousel recyclerview in koltin files (activity or fragment) with attribute.

  binding.carouselRecyclerview.adapter = adapter
  binding.carouselRecyclerview.apply {
   set3DItem(true)
   setAlpha(true)
   setInfinite(true)
  }

Basic Example for XML

Here is a basic example of implementing carousel recyclerview in layout xml.

<com.jackandphantom.carouselrecyclerview.CarouselRecyclerview
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:id="@+id/carouselRecyclerview"/>
Property infinite and 3D on Item enabled Property infinite and alpha on Item enabled

API Methods

Method Description Default
fun set3DItem(is3DItem: Boolean) Make the view tilt according to their position, middle position does not tilt. false
fun setInfinite(isInfinite: Boolean) Create the loop of the given view means there is no start or end, but provided position in the interface will be correct. false
fun setFlat(isFlat: Boolean) Make the flat layout in the layout manager of the reyclerview false
fun setAlpha(isAlpha: Boolean) Set the alpha for each item depends on the position in the layout manager false
fun setIntervalRatio(ratio: Float) Set the interval ratio which is gap between items (views) in layout manager 0.5f (value of gap, it should in range (0.4f - 1f))
fun getCarouselLayoutManager(): CarouselLayoutManager Get the carousel layout manager instance
fun getSelectedPosition(): Int Get selected position from the layout manager center view Position
fun setIsScrollingEnabled(isScrollingEnabled: Boolean) Set scrolling disabled or enabled true
fun setOrientation(@Orientation orientation: Int) Set layout orientation RecyclerView.HORIZONTAL

Vertical Orientation Preview

Property infinite and 3D on Item enabled

API Methods Usage

val carouselRecyclerview = findViewById<CarouselRecyclerview>(R.id.recycler)
      carouselRecyclerview.adapter = adapter
      carouselRecyclerview.set3DItem(true)
      carouselRecyclerview.setInfinite(true)
      carouselRecyclerview.setAlpha(true)
      carouselRecyclerview.setFlat(true)
      carouselRecyclerview.setIsScrollingEnabled(true)

      val carouselLayoutManager = carouselRecyclerview.getCarouselLayoutManager()
      val currentlyCenterPosition = carouselRecyclerview.getSelectedPosition()

Item Position Listener

You can listen to the position whenever the scroll happens you will get notified about the position, following are codes for listener

 carouselRecyclerview.setItemSelectListener(object : OnSelected {
          override fun onItemSelected(position: Int) {
              //Cente item
          }
      })

Reflection ImageView

You see in the demo that there is a mirror image (reflection imageview), for this i already created custom imageview for this.

Use ReflectionImageView in xml layout and provide src

 <com.jackandphantom.carouselrecyclerview.view.ReflectionImageView
     android:layout_width="120dp"
     android:layout_height="120dp"
     android:scaleType="fitXY"
     android:src="@drawable/hacker"
    />

Reflection Layout

Now you can show reflection in more efficient way and 3x faster than ReflectionImageView see the codes below

<?xml version="1.0" encoding="utf-8"?>
<com.jackandphantom.carouselrecyclerview.view.ReflectionViewContainer
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    xmlns:android="http://schemas.android.com/apk/res/android"
    app:reflect_relativeDepth="0.5"
    app:reflect_gap="0dp"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    >
    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/guypro"
        android:scaleType="fitXY"
        android:id="@+id/image" />
</com.jackandphantom.carouselrecyclerview.view.ReflectionViewContainer>

Notes about Reflection imageview

I would recommend you to use image loading library like Glide for loading image in reflection image for better performance

Contribute 🀝

If you like the project and somehow wants to contribute, you are welcome to contribute by either submitting issues, refactor, pull request Thankyou.

Contributors ✨

Thanks go to these wonderful people :


Snehil

πŸ’»

Mattias Rosberg

πŸ’»

AKASH PATEL

πŸ’»

Night Wolf

πŸ’»

Find this repository useful? ❀️

Support it by joining stargazers for this repository. ⭐
And follow me for next creation 🀩

License

Copyright 2021 Sparrow007 (Ankit kumar)

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.

More Repositories

1

CircularProgressbar

CircularProgressbar project let you create circular progressbar in android
Java
211
star
2

BlurImage

This Android Project help you to make your image blur in fastest way
Java
184
star
3

CircularImageview

This project allowing you to create circular and rounded corner Imageview in android through simplest way.
Java
96
star
4

AndroidLikeButton

This library will help you to create animation like twitter heart and facebook like and smiley animation in simplest way
Java
89
star
5

CustomToggleButton

This Project let you create the custom toggleButton with beautiful animation in a simplest way
Java
87
star
6

AndroidJoyStickView

This library lets you create joystick with some customization for android
Java
48
star
7

PaletteShadowView

This library shows the shadow of the image by it's palette color.
Java
32
star
8

InstagramVideoButton

This library is inspired by the instagram video button having the same animation, look and feel.
Kotlin
28
star
9

Custom-Views-Android

This repository contains different custom views with animations
Kotlin
14
star
10

Notes-App

Android application which will create your notes, that will help you to write your thoughts, work related task and anything which you will need in future.
Kotlin
11
star
11

Android-Portfolio

This is my portfolio as a developer
8
star
12

Message_App

This is message app using google firebase
Java
6
star
13

Custom-VIew-Learning

This repo is only for learning the custom view and implementing different view such as a custom view, layout manager in recylcerview and many more.
Kotlin
2
star
14

-legendary-succotash

1
star
15

Quiz

This is assignment
Java
1
star
16

TrendingMovies

MVVM Architecture, LiveData, Dagger-2, Viepager, Coroutin and, Retrofit,
Kotlin
1
star
17

music

1
star
18

Music_APP

1
star
19

RecylcerView_Example

Java
1
star
20

CardViewExperiment

Java
1
star
21

RecylerViewApp

Java
1
star