Gradle
Add below codes to your root build.gradle file (not your module build.gradle file).
allprojects {
repositories {
mavenCentral()
}
}
Gradle
And add a dependency code to your module's build.gradle file.
dependencies {
implementation 'com.github.sparrow007:carouselrecyclerview:1.2.1'
}
Basic Example for Kotlin
Here is a basic example of implementing carousel recyclerview in koltin files (activity or fragment) with attribute.
val carouselRecyclerview = findViewById<CarouselRecyclerview>(R.id.recycler)
carouselRecyclerview.adapter = adapter
Kotlin
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/recycler"/>
API Methods
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)
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>
ReplyDeleteThanks for this information. it is helpfull and worthy
Laptop Repair Center offers quality service for your laptop at a reasonable cost. We offer doorstep support, 24*7 onsite support, repair all brand laptops, have an expert team for onsite support, and much more. for more contact us on 7291903784
laptop repair center in Delhi
i found it very helpful. thank u
ReplyDeleteMast Banarasi Paan is one of the best selling paan such as Rajwadi paan, Laddu paan, Choclate Paan, Fire paan, Silver paan. Mast Banarasi Paan is made available to every customer with unique flavor, quality taste, and hygiene and we are the best paan provider in India.
banarasi paan