Interactive Carousel in Android

前提是你 提交于 2020-01-07 03:50:12

问题


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:

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!


回答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
    }
};


来源:https://stackoverflow.com/questions/35611720/interactive-carousel-in-android

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!