An amazing and convenient Android image slider.

Overview

Android Image Slider Build Status

![Gitter](https://badges.gitter.im/Join Chat.svg)

This is an amazing image slider for the Android platform. I decided to open source this because there is really not an attractive, convenient slider widget in Android.

You can easily load images from an internet URL, drawable, or file. And there are many kinds of amazing animations you can choose. :-D

Demo

Download Apk

Usage

Step 1

Gradle

dependencies {
    	compile "com.android.support:support-v4:+"
    	compile 'com.squareup.picasso:picasso:2.3.2'
    	compile 'com.nineoldandroids:library:2.4.0'
    	compile 'com.daimajia.slider:library:1.1.5@aar'
}

Maven

<dependency>
    <groupId>com.squareup.picasso</groupId>
    <artifactId>picasso</artifactId>
    <version>2.3.2</version>
</dependency>
<dependency>
    <groupId>com.nineoldandroids</groupId>
    <artifactId>library</artifactId>
    <version>2.4.0</version>
</dependency>
<dependency>
    <groupId>com.daimajia.slider</groupId>
    <artifactId>library</artifactId>
    <version>1.1.2</version>
    <type>apklib</type>
</dependency>

Eclipse

For Eclipse users, I provided a sample project which orgnized as Eclipse way. You can download it from here, and make some changes to fit your project.

Notice: It's the version of 1.0.9, it may not update any more. You can update manually by yourself.

Step 2

Add permissions (if necessary) to your AndroidManifest.xml

<!-- if you want to load images from the internet -->
<uses-permission android:name="android.permission.INTERNET" /> 

<!-- if you want to load images from a file OR from the internet -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

Note: If you want to load images from the internet, you need both the INTERNET and READ_EXTERNAL_STORAGE permissions to allow files from the internet to be cached into local storage.

If you want to load images from drawable, then no additional permissions are necessary.

Step 3

Add the Slider to your layout:

<com.daimajia.slider.library.SliderLayout
        android:id="@+id/slider"
        android:layout_width="match_parent"
        android:layout_height="200dp"
/>

There are some default indicators. If you want to use a provided indicator:

<com.daimajia.slider.library.Indicators.PagerIndicator
        android:id="@+id/custom_indicator"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center"
        />

Code example

====

Advanced usage

Please visit Wiki

Thanks

##About me

I am a student in mainland China. I love Google, love Android, love everything that is interesting. If you get any problems when using this library or you have an internship opportunity, please feel free to email me. 😃

Comments
  • Current count of the page in TextSlider?

    Current count of the page in TextSlider?

    I am loading all images using Picasso into TextSlider. I want to set wallpaper using onSliderClick(BaseSliderView slider) method. But, there is no such method. I am storing all the URLs in an array. So, i need the current position so that I can pass it in array and save the particular image.

    opened by Chirag-Galani 28
  • Hey, guys, I need your help.

    Hey, guys, I need your help.

    I'm the author of this library, and the authors of some other libraries.

    Most of them looks pretty popular, I can receive many issues and pull request everyday. The problem is I can not hanlde each of them in time, cause I have started a startup with my friends in the past few months, startup is a really hard time, I can not devote all my time to open source right now.

    So, I really need your help, I need some collaborators to participate in this project or others.

    If you would like to be one of the collaborator, please feel free to comment below.

    opened by daimajia 19
  • Added a OnPageChangeListener to the SliderLayout

    Added a OnPageChangeListener to the SliderLayout

    I implemented the ArrayList of listeners in ViewPagerEx as you recommended and used the item count in the InfinitePager to calculate the page number. I also implemented the listener in the demo with a simple log.

    opened by massimobio 17
  • .setCuurentPosition hangs when traversing backwards

    .setCuurentPosition hangs when traversing backwards

    Hi, I found an issue when using setCurrentPosition method while traversing backwards. Suppose I am at slide no 1 and called .setCurrentPosition method to set current slide index to 5, it will work, but if I call .setCurrentPosition from 5th index to say 3rd then the application hangs. I'm getting the following error in doing so: E/dalvikvm﹕ Fatal spin-on-suspend, dumping threads

    opened by nitin84india 14
  • No style applied

    No style applied

    Hello there! I'm using the library and it works perfect. The only problem I have is that you can not apply styles

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:custom="http://schemas.android.com/apk/res-auto"
        android:id="@+id/viewFlipper"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:addStatesFromChildren="true"
        android:background="@color/azul_us"
        android:orientation="vertical" >
    
     <com.daimajia.slider.library.SliderLayout
            android:id="@+id/slider"
            android:layout_width="match_parent"
            android:layout_height="200dp" />
    
        <com.daimajia.slider.library.Indicators.PagerIndicator
            android:id="@+id/custom_indicator"
            style="@style/AndroidImageSlider_Magnifier_Oval_Black" />
    </LinearLayout>
    
    
      <style name="AndroidImageSlider_Magnifier_Oval_Black">
            <item name="android:layout_width">wrap_content</item>
            <item name="android:layout_height">wrap_content</item>
            <item name="android:gravity">right</item>
            <item name="android:paddingLeft">2dp</item>
            <item name="android:paddingRight">2dp</item>
            <item name="shape">rect</item>
            <item name="padding_left">3dp</item>
            <item name="padding_right">3dp</item>
            <item name="padding_top">4dp</item>
            <item name="padding_bottom">4dp</item>
    
            <item name="selected_color">#7ac943</item>
            <item name="unselected_color">#33000000</item>
            <item name="selected_width">8dp</item>
            <item name="selected_height">8dp</item>
            <item name="unselected_width">6dp</item>
            <item name="unselected_height">6dp</item>
        </style>
    

    Thanks!!

    screenshot_2014-08-22-07-27-29

    opened by benoffi7 10
  • Scaling options for  Images

    Scaling options for Images

    While I added few Image urls the slider works fine. but I am unable to get the Image from the Slider so that I can set its ScaleType to something center, fitxy, centerCrop etc.

    Any workaround to get the image from the slider before or after adding it to the slider.

    enhancement 
    opened by rinav 10
  • How to hide progress and stop scrolling

    How to hide progress and stop scrolling

    Hi, i have two questions:

    1. How to stop scrolling when one image ? I use "sliderShow.stopAutoCycle();", but how to disable for user it?
    2. I have problem when just one image in slider, problem with progress loading, he not hide if used "sliderShow.stopAutoCycle();".

    And thank you for this great library.

    bug 
    opened by wakirin 9
  • how to disable image caching

    how to disable image caching

    I want the images loaded from URL. the images may change every week. the slider won't load and show new images on the URL. what should I do to disable caching? I also cleared app's data but couldn't get new Images. here's my code from sample:

    for (String name : imgList) {
    TextSliderView textSliderView = new TextSliderView(mActivity);
                textSliderView
                        .description("")
                        .image(mActivity.getString(R.string.temp_url) + name)
                        .setScaleType(BaseSliderView.ScaleType.CenterCrop);
                textSliderView.bundle(new Bundle());
                textSliderView.getBundle()
                        .putString("extra", "");
    
                mDemoSlider.addSlider(textSliderView);
    }
    
    opened by Lithium-HD 8
  • Unable to Hide Text

    Unable to Hide Text

    I been fiddling with this all day, and cannot get this to work.

    I am trying to remove the Text and Bar / images from the image slider, as i only want the images.

    My Current code looks like : DemoActivity.java

    
    import android.graphics.Color;
    import android.os.Bundle;
    import android.support.v7.app.ActionBarActivity;
    import android.view.Menu;
    import android.view.MenuInflater;
    import com.daimajia.slider.library.SliderLayout;
    import com.daimajia.slider.library.SliderTypes.BaseSliderView;
    import com.daimajia.slider.library.SliderTypes.TextSliderView;
    import com.daimajia.slider.library.Tricks.ViewPagerEx;
    import java.util.HashMap;
    
    
    public class DemoActivity extends ActionBarActivity implements CustomSliderView.OnSliderClickListener, ViewPagerEx.OnPageChangeListener{
    
        private SliderLayout mDemoSlider;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_demo);
            mDemoSlider = (SliderLayout)findViewById(R.id.slider);
    
            HashMap<String,String> url_maps = new HashMap<String, String>();
            url_maps.put("Hannibal", "http://static2.hypable.com/wp-content/uploads/2013/12/hannibal-season-2-release-date.jpg");
            url_maps.put("Big Bang Theory", "http://tvfiles.alphacoders.com/100/hdclearart-10.png");
            url_maps.put("House of Cards", "http://cdn3.nflximg.net/images/3093/2043093.jpg");
            url_maps.put("Game of Thrones", "http://images.boomsbeat.com/data/images/full/19640/game-of-thrones-season-4-jpg.jpg");
    
            HashMap<String,Integer> file_maps = new HashMap<String, Integer>();
            file_maps.put("Hannibal",R.drawable.hannibal);
            file_maps.put("Big Bang Theory",R.drawable.bigbang);
            file_maps.put("House of Cards",R.drawable.house);
            file_maps.put("Game of Thrones", R.drawable.game_of_thrones);
    
            for(String name : file_maps.keySet()){
                TextSliderView textSliderView = new TextSliderView(this);
                // initialize a SliderLayout
                textSliderView
                        .image(file_maps.get(name))
                        .setScaleType(CustomSliderView.ScaleType.Fit)
    
                        .setOnSliderClickListener(this);
    
                mDemoSlider.setBackgroundColor(Color.TRANSPARENT);
    
                mDemoSlider.addSlider(textSliderView);
            }
            mDemoSlider.setPresetTransformer(SliderLayout.Transformer.Accordion);
            mDemoSlider.setDuration(4000);
            mDemoSlider.addOnPageChangeListener(this);
    
    
    
        }
    
        @Override
        protected void onStop() {
            // To prevent a memory leak on rotation, make sure to call stopAutoCycle() on the slider before activity or fragment is destroyed
            mDemoSlider.stopAutoCycle();
            super.onStop();
        }
    
        @Override
        public void onSliderClick(BaseSliderView slider) {
        }
    
        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            MenuInflater menuInflater = getMenuInflater();
            menuInflater.inflate(R.menu.main,menu);
            return super.onCreateOptionsMenu(menu);
        }
    
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {}
    
        @Override
        public void onPageSelected(int position) {
        }
    
        @Override
        public void onPageScrollStateChanged(int state) {}
    }
    
    

    Layout:

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:custom="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context="com.tapnbe.tapnbe.DemoActivity">
        <com.daimajia.slider.library.SliderLayout
            android:id="@+id/slider"
            android:layout_width="match_parent"
            custom:pager_animation="Accordion"
            custom:auto_cycle="false"
            custom:indicator_visibility="invisible"
            custom:pager_animation_span="1100"
            android:background="@color/zxing_transparent"
            android:layout_height="200dp"/>
    
        <com.daimajia.slider.library.Indicators.PagerIndicator
            android:id="@+id/custom_indicator"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            custom:selected_color="#0095BF"
            custom:unselected_color="#55333333"
            custom:selected_drawable="@drawable/bird"
            custom:shape="oval"
            custom:selected_padding_left="5dp"
            custom:selected_padding_right="5dp"
            custom:unselected_padding_left="5dp"
            custom:unselected_padding_right="5dp"
            android:layout_centerHorizontal="true"
            android:layout_alignParentBottom="true"
            custom:selected_width="6dp"
            custom:selected_height="6dp"
            custom:unselected_width="6dp"
            custom:unselected_height="6dp"
            android:layout_marginBottom="20dp"
            />
        <ListView
            android:layout_below="@+id/slider"
            android:id="@+id/transformers"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"></ListView>
    
    
    </RelativeLayout>
    

    and my Gradle Imports:

    
        compile "com.android.support:support-v4:+"
        compile 'com.squareup.picasso:picasso:2.3.2'
        compile 'com.nineoldandroids:library:2.4.0'
        compile 'com.daimajia.slider:library:1.1.5@aar'
        compile 'com.daimajia.androidanimations:library:1.1.3@aar'
    
    
    

    I have added a CustomSliderView.java in my program and added but does not work:

    import android.content.Context;
    import android.graphics.Color;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.widget.ImageView;
    import android.widget.LinearLayout;
    import com.daimajia.slider.library.R.id;
    import com.daimajia.slider.library.R.layout;
    import com.daimajia.slider.library.SliderTypes.BaseSliderView;
    
    public class CustomSliderView extends BaseSliderView {
    
        public CustomSliderView(Context context) {
            super(context);
        }
    
        public View getView() {
    
            View v = LayoutInflater.from(this.getContext()).inflate(layout.render_type_text, null);
            ImageView target = (ImageView) v.findViewById(id.daimajia_slider_image);
            LinearLayout frame = (LinearLayout) v.findViewById(id.description_layout);
            frame.setBackgroundColor(Color.TRANSPARENT);
            this.bindEventAndShow(v, target);
    
            return v;
        }
    
    
    opened by tapnikita 7
  • looking for this library for eclipse

    looking for this library for eclipse

    HI thanks you for this perfect library . The problem is that i'm using eclipse like thousand of others but we can't use this library for eclipse . I was wondering if someone convert this library to eclipse ? I've tried very much to do this but I couldn't .

    if anyone has this library for eclipse , please share it with others thanks you

    opened by abc2005 7
  • modify the logic about removing or adding slides dynamically

    modify the logic about removing or adding slides dynamically

    1. Disable slide (not autocycle) when theres only one image? #82 …
    2. Modify PagerIndicator show wrong numbers of indicators when call removeSliderAt
    3. modify ViewPager scroll logic when SliderAdapter data change. avoid slide around a bunch on initializing after removing or adding slides dynamically
    opened by zhouqiangWang 6
  • Hide progress bar and throw callback listener when image is loaded from url

    Hide progress bar and throw callback listener when image is loaded from url

    Hi, I want to hide progress bar, I don't want it to be visible at all. Second I want a callback/listener when image is loaded from the given Url. I am using DefaultSliderView, I am loading images from the links. I want a callback/listener whenever my images are loaded successfully.

    opened by FaizanAhmad196 2
  • Error inflating class com.daimajia.slider.library.SliderLayout

    Error inflating class com.daimajia.slider.library.SliderLayout

    I have been trying to inflate this SliderLayout in a Fragment. I am getting this error. So please help me to resolve this error. Binary XML file line https://github.com/daimajia/AndroidImageSlider/issues/8 in : Error inflating class com.daimajia.slider.library.SliderLayout Caused by: java.lang.reflect.InvocationTargetException Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.daimajia.slider.library.Tricks.InfiniteViewPager.setAdapter(androidx.viewpager.widget.PagerAdapter)' on a null object reference

    opened by Himanshu08279827 0
  • Left and right arrow

    Left and right arrow

    Hi, I'm happy to found out your library, it is extremely handy.

    I want to add left and right click arrow functions to the change the slide. Can you please help me out here?

    opened by karthysbk 1
  • Deprecated! This library really needs the update

    Deprecated! This library really needs the update

    This library has been deprecated and really need to update as the last version updated 7 years ago. It's creating issue in androix and unable to inflate some classes.

    opened by imafzalakram 0
  • Error inflating class com.daimajia.slider.library.SliderLayout

    Error inflating class com.daimajia.slider.library.SliderLayout

    I have been trying to inflate this SliderLayout in a Fragment. I am getting this error. So please help me to resolve this error. Binary XML file line #8 in : Error inflating class com.daimajia.slider.library.SliderLayout Caused by: java.lang.reflect.InvocationTargetException Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.daimajia.slider.library.Tricks.InfiniteViewPager.setAdapter(androidx.viewpager.widget.PagerAdapter)' on a null object reference

    opened by varundhuria 2
Owner
代码家
Zhenfund Associate, bp [email protected]
代码家
A simple and customizable Android full-screen image viewer with shared image transition support, "pinch to zoom" and "swipe to dismiss" gestures

Stfalcon ImageViewer A simple and customizable full-screen image viewer with shared image transition support, "pinch to zoom" and "swipe to dismiss" g

Stfalcon LLC 1.9k Jan 5, 2023
AndroidPhotoFilters aims to provide fast, powerful and flexible image processing instrument for creating awesome effects on any image media.

PhotoFiltersSDK PhotoFiltersSDK aims to provide fast, powerful and flexible image processing instrument for creating awesome effects on any image medi

Zomato 2.5k Dec 23, 2022
Image-search - An Image search android app with offline support

image-search Image search app built using bing image search API via paging 3. Fe

Suraj Vaishnav 3 Feb 17, 2022
Chandrasekar Kuppusamy 799 Nov 14, 2022
A Photo Editor library with simple, easy support for image editing using paints,text,filters,emoji and Sticker like stories.

PhotoEditor A Photo Editor library with simple, easy support for image editing using Paints, Text, Filters, Emoji and Sticker like stories. Features D

Burhanuddin Rashid 3.6k Jan 9, 2023
Road Runner is a library for android which allow you to make your own loading animation using a SVG image

Road Runner Road Runner is a library for android which allow you to make your own loading animation using a SVG image Sample video View in Youtube Dem

Adrián Lomas 1.2k Nov 18, 2022
MIPagerTransformer is an android library that provides a seamless image transformation experience.

MIPagerTransformerView -- MIPagerTransformer is an android library that provides a seamless image transformation experience. Overview ?? Shutter ?? Pa

MindInventory 21 Sep 17, 2022
Material image loading implementation

MaterialImageLoading Material image loading implementation Sample And have a look on a sample Youtube Video : Youtube Link [] (https://www.youtube.com

Florent CHAMPIGNY 392 Nov 17, 2022
Animate a strike over any image to indicate on/off states. As seen in the Material Guidelines.

StrikedImageView Animate a strike over any image to indicate on/off states. As seen in the Material Guidelines. Gradle allprojects { repositories

null 9 Sep 21, 2022
Render After Effects animations natively on Android and iOS, Web, and React Native

Lottie for Android, iOS, React Native, Web, and Windows Lottie is a mobile library for Android and iOS that parses Adobe After Effects animations expo

Airbnb 33.5k Jan 4, 2023
A Simple Todo app design in Flutter to keep track of your task on daily basis. Its build on BLoC Pattern. You can add a project, labels, and due-date to your task also you can sort your task on the basis of project, label, and dates

WhatTodo Life can feel overwhelming. But it doesn’t have to. A Simple To-do app design in flutter to keep track of your task on daily basis. You can a

Burhanuddin Rashid 1k Jan 1, 2023
FilePicker is a small and fast file selector library that is constantly evolving with the goal of rapid integration, high customization, and configurability~

Android File Picker ??️ 中文简体 Well, it doesn't have a name like Rocky, Cosmos or Fish. Android File Picker, like its name, is a local file selector fra

null 786 Jan 6, 2023
Android Country Picker is a Kotlin-first, flexible and powerful Android library that allows to integrate Country Picker with just a few lines.

1. Add dependency dependencies { implementation 'com.hbb20:android-country-picker:X.Y.Z' } For latest version, 2. Decide your use-case

Harsh B. Bhakta 65 Dec 6, 2022
[] Easily have blurred and transparent background effect on your Android views.

##[DEPRECATED] BlurBehind Easily have blurred and transparent background effect on your Android views. Before API level 14 there was a Window flag cal

Gokberk Ergun 516 Nov 25, 2022
Android StackBlur is a library that can perform a blurry effect on a Bitmap based on a gradient or radius, and return the result. The library is based on the code of Mario Klingemann.

Android StackBlur Android StackBlur is a library that can perform a blurry effect on a Bitmap based on a gradient or radius, and return the result. Th

Enrique López Mañas 3.6k Dec 29, 2022
Android library. Flexible components for chat UI implementation with flexible possibilities for styling, customizing and data management. Made by Stfalcon

ChatKit for Android ChatKit is a library designed to simplify the development of UI for such a trivial task as chat. It has flexible possibilities for

Stfalcon LLC 3.6k Jan 5, 2023
Android library to animate Floating Action Button to Bottom Sheet Dialog and vice-versa

FabulousFilter Show some ❤️ and star the repo to support the project This library is the implementation of filter-concept posted on MaterialUp.com. It

Krupen Ghetiya 2.6k Jan 3, 2023
FPSAnimator is very easy animation library for Android TextureView and SurfaceView.

FPSAnimator A simple but powerful Tween / SpriteSheet / ParabolicMotion / animation library for Android TextureView and SurfaceView. Features The cont

Masayuki Suda 756 Dec 30, 2022
How to apply meaningful and delightful motion in a sample Android app

Applying meaningful motion on Android How to apply meaningful and delightful motion in a sample Android app Read the complete post at https://medium.c

André Mion 166 Nov 12, 2022