0

I want to make a carousel in Android but must be an interactive one.

I tryed to use this library https://github.com/jacevedo/Android-Apps but i didn't work how i wan't.

What i need is Something like:

enter image description here

The idea is: when a color is clicked the picture change its color with setTint(). If the picture changes the color keep the selected color.

I need that be compatible with android 4.2

Any library or any guide that works similar?

Thanks!

Alejandro Liébana
  • 290
  • 1
  • 2
  • 15
  • for those who don't want to use a library, check this: https://stackoverflow.com/questions/38459309/how-do-you-create-an-android-view-pager-with-a-dots-indicator – BabyishTank Jun 23 '21 at 05:14

1 Answers1

1

You can try CarouselView library.
Include the following code view 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"/>


carouselView = (CarouselView) findViewById(R.id.carouselView);
carouselView.setPageCount(sampleImages.length);
carouselView.setImageListener(imageListener);
carouselView.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        @Override
        public void onPageSelected(int position) {
            // Do your desired action
        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }
    });


ImageListener imageListener = new ImageListener() {
    @Override
    public void setImageForPosition(int position, ImageView imageView) {
        // Set the desired picture
    }
};
Rehan
  • 3,270
  • 5
  • 31
  • 30