Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

License

NotificationsYou must be signed in to change notification settings

sparrow007/CarouselRecyclerview

Repository files navigation

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


Build StatusLicenseLicenseLicenseAndroidWeekly


Layout manager

Including in your project

Maven Central with version prefix filterCarouselRecyclerview

Gradle

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

allprojects {    repositories {          mavenCentral()    }}

And add a dependency code to yourmodule'sbuild.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.CarouselRecyclerviewandroid:layout_width="match_parent"android:layout_height="wrap_content"android:id="@+id/carouselRecyclerview"/>
Property infinite and 3D on Item enabledProperty infinite and alpha on Item enabled

API Methods

MethodDescriptionDefault
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 reyclerviewfalse
fun setAlpha(isAlpha: Boolean)Set the alpha for each item depends on the position in the layout managerfalse
fun setIntervalRatio(ratio: Float)Set the interval ratio which is gap between items (views) in layout manager0.5f (value of gap, it should in range (0.4f - 1f))
fun getCarouselLayoutManager(): CarouselLayoutManagerGet the carousel layout manager instance
fun getSelectedPosition(): IntGet selected position from the layout managercenter view Position
fun setIsScrollingEnabled(isScrollingEnabled: Boolean)Set scrolling disabled or enabledtrue
fun setOrientation(@Orientation orientation: Int)Set layout orientationRecyclerView.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 {overridefunonItemSelected(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.ReflectionImageViewandroid: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.ReflectionViewContainerandroid: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"    >    <ImageViewandroid: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 joiningstargazers for this repository. ⭐
Andfollow 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.0Unless required by applicable law or agreed to in writing, softwaredistributed 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 andlimitations under the License.

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors6

Languages


[8]ページ先頭

©2009-2025 Movatter.jp