Giter Club home page Giter Club logo

slider-image-arrow's Introduction

Slider Image Arrow

This is a simple image slider in android with images as a thumbnails, It uses simple viewpager and recyclerview to display images in collapsible toolbar.

This library supports AndroidX

DEMO

Alt text

Add in your Android Project

  • Gradle

Step 1. Add it in your root build.gradle at the end of repositories:

allprojects {
        repositories {
            ...
            maven { url 'https://jitpack.io' }
        }
    }

Step 2. Add the dependency

dependencies {
        implementation 'com.github.felipepalma14:slider-image-arrow:Tag'
}

Integration Guide

    <androidx.constraintlayout.widget.ConstraintLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".SliderSampleActivity">
    
        <com.felipepalma14.sliderimagearrow.view.SliderView
            android:id="@+id/sliderView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toTopOf="parent">
    
        </com.felipepalma14.sliderimagearrow.view.SliderView>
    </androidx.constraintlayout.widget.ConstraintLayout>

Slider Adapter

    public class SliderAdapterExample extends SliderViewAdapter<SliderAdapterExample.SliderAdapterViewHolder> {
        
            private List<String> photoList;
        
            public SliderAdapterExample(List<String> photoList) {
                this.photoList = photoList;
            }
        
            @Override
            public SliderAdapterViewHolder onCreateViewHolder(ViewGroup parent) {
                @SuppressLint("InflateParams") View inflate = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_image_slider, null);
                return new SliderAdapterViewHolder(inflate);
            }
        
            @Override
            public void onBindViewHolder(SliderAdapterViewHolder viewHolder, int position) {
        
                Glide.with(viewHolder.itemView)
                        .load(photoList.get(position))
                        .centerCrop()
                        .diskCacheStrategy(DiskCacheStrategy.ALL)
                        .into(viewHolder.backgroundImageView);
            }
        
            @Override
            public int getCount() {
                return photoList.size();
            }
        
        
            class SliderAdapterViewHolder extends SliderViewAdapter.ViewHolder {
        
                View itemView;
                ImageView backgroundImageView;
        
                SliderAdapterViewHolder(View itemView) {
                    super(itemView);
                    backgroundImageView = itemView.findViewById(R.id.iv_auto_image_slider);
                    this.itemView = itemView;
                }
            }
        }
        
    

Set the adapter to the Sliderview

    sliderView.setSliderAdapter(new SliderAdapterExample(context));

In Activity

    public class SliderSampleActivity extends AppCompatActivity {
    
        SliderView sliderView;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_slider_sample);
    
            sliderView = findViewById(R.id.sliderView);
            List<String> images =  Arrays.asList( getResources().getStringArray(R.array.user_photos));
            final SliderAdapterExample adapter  = new SliderAdapterExample(images);
    
            sliderView.setSliderAdapter(adapter);
    
    
        }
    }

Change thumbnails lines color

    <color name="colorAccent">#ccb3ff</color>

slider-image-arrow's People

Contributors

9stack avatar felipepalma14 avatar sunnag7 avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.