Is there any library available for Carousel animation of images?
I found http://www.androidviews.net/2012/10/android-coverflow/ ; https://code.google.com/p/android-coverflow/ but this library/snippet use extends gallay (Gallery class was deprecated in API level 16. (4.1.2)), so is there any (modern) library? Maybe in combination with picasso?
Here is the free link of CarouselView Github Link and Android Arsenal
Gradle:
compile 'com.synnapps:carouselview:0.0.7'
Maven:
<dependency>
<groupId>com.synnapps</groupId>
<artifactId>carouselview</artifactId>
<version>0.0.7</version>
<type>pom</type>
</dependency>
Usage:
Include following code in your layout:
<com.synnapps.carouselview.CarouselView
android:id="@+id/carouselView"
android:layout_width="match_parent"
android:layout_height="200dp"
app:fillColor="#FFFFFFFF"
app:pageColor="#00000000"
app:radius="6dp"
app:slideInterval="3000"
app:strokeColor="#FF777777"
app:strokeWidth="1dp"/>
Include following code in your activity:
public class SampleCarouselViewActivity extends AppCompatActivity {
CarouselView carouselView;
int[] sampleImages = {R.drawable.image_1, R.drawable.image_2, R.drawable.image_3, R.drawable.image_4, R.drawable.image_5};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sample_carousel_view);
carouselView = (CarouselView) findViewById(R.id.carouselView);
carouselView.setPageCount(sampleImages.length);
carouselView.setImageListener(imageListener);
}
ImageListener imageListener = new ImageListener() {
@Override
public void setImageForPosition(int position, ImageView imageView) {
imageView.setImageResource(sampleImages[position]);
}
};
}
If you want to add custom view, implement ViewListener.
public class SampleCarouselViewActivity extends AppCompatActivity {
CarouselView customCarouselView;
int NUMBER_OF_PAGES = 5;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sample_carousel_view);
customCarouselView = (CarouselView) findViewById(R.id.customCarouselView);
customCarouselView.setPageCount(NUMBER_OF_PAGES);
// set ViewListener for custom view
customCarouselView.setViewListener(viewListener);
}
ViewListener viewListener = new ViewListener() {
@Override
public View setViewForPosition(int position) {
View customView = getLayoutInflater().inflate(R.layout.view_custom, null);
//set view attributes here
return customView;
}
};
For more information go to github link