Giter VIP home page Giter VIP logo

imageslideshow's Introduction

Android Image Slider

Just add the images you want to view.

  • Easy to use.
  • Automatic scrolling for the time you set.
  • Add any caption to the images.
  • 14 different slide animations.
  • Adjust corner radius images.
  • Use with Java or Kotlin.


    Android Arsenal license Codacy Badge

    Usage

    • Add ImageSlider to your layout
    <com.denzcoskun.imageslider.ImageSlider    
         android:id="@+id/image_slider"    
         android:layout_width="wrap_content"    
         android:layout_height="300dp"    
         app:iss_auto_cycle="true"    
         app:iss_period="1000"    
         app:iss_delay="1000"    
         app:iss_text_align="CENTER"/>  
    • You can change placeholder image.
     app:iss_placeholder="@drawable/placeholder"  
    • You can change error image.
     app:iss_error_image="@drawable/error"  
    • You can change indicators.
    app:iss_selected_dot="@drawable/default_selected_dot"  
    app:iss_unselected_dot="@drawable/default_unselected_dot"  
    • Add ImageSlider to your Activity
    val imageList = ArrayList<SlideModel>() // Create image list  
      
    // imageList.add(SlideModel("String Url" or R.drawable)  
    // imageList.add(SlideModel("String Url" or R.drawable, "title") You can add title  
      
    imageList.add(SlideModel("https://bit.ly/2YoJ77H", "The animal population decreased by 58 percent in 42 years."))  
    imageList.add(SlideModel("https://bit.ly/2BteuF2", "Elephants and tigers may become extinct."))  
    imageList.add(SlideModel("https://bit.ly/3fLJf72", "And people do that."))  
      
    val imageSlider = findViewById<ImageSlider>(R.id.image_slider)  
    imageSlider.setImageList(imageList)  
    • You can change scaleType for all images or one image.
    import com.denzcoskun.imageslider.constants.ScaleTypes // important  
      
    // FIT, CENTER_CROP or CENTER_INSIDE  
      
    imageList.add(SlideModel("String Url" or R.drawable, ScaleTypes.FIT) // for one image  
    imageList.add(SlideModel("String Url" or R.drawable, "Title", ScaleTypes.FIT) // you can with title  
      
    imageSlider.setImageList(imageList, ScaleTypes.FIT) // for all images  
    • You can change title background on xml.
     app:iss_title_background="@drawable/gradient" //or app:iss_title_background="@android:color/holo_red_light"  
    • Also change text color on xml. It is default white.
     app:iss_text_color="#FFA0A0"   
    • Indicators can be remove.
     app:iss_no_dots="true"   
    • You can use click listener or double click listener.
    imageSlider.setItemClickListener(object : ItemClickListener {    
        override fun onItemSelected(position: Int) {    
            // You can listen here.  
     }      
        override fun doubleClick(position: Int) {    
           // Do not use onItemSelected if you are using a double click listener at the same time.    
           // Its just added for specific cases.   
           // Listen for clicks under 250 milliseconds.  
     } })  
    • You can add animation like that, 14 Animations added. You can check in Animation List
    imageSlider.setSlideAnimation(AnimationTypes.ZOOM_OUT)  
    • You can add stop and start auto sliding again.
    imageSlider.startSliding(3000) // with new period  
    imageSlider.startSliding()  
    imageSlider.stopSliding()  

    Setup

    allprojects {
    	repositories {
    		...
    		maven { url 'https://jitpack.io' }
    	}
    }
    
    dependencies {
    	implementation 'com.github.denzcoskun:ImageSlideshow:0.1.2'
    }

    📄 License

    Copyright 2019 Deniz Coşkun

    Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

    License

    Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and limitations under the License.

  • imageslideshow's People

    Contributors

    denzcoskun avatar

    Stargazers

     avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

    Watchers

     avatar  avatar  avatar  avatar  avatar  avatar

    imageslideshow's Issues

    Cannot resolve constructor 'SlideModel(java.lang.String)'

    Hello, today I updated to version 0.1.0 of the library and ran into a problem that this code stopped working for me. I work in Java, and the shown example on Kotlin worked for me, but alas, nothing in Java.

    I would really thank you for your help, thank you.

    `List slideModels = new ArrayList<>();

        for (String s : sub_uris_list) {
            slideModels.add(new SlideModel(s));
        }
    
        imageSlider.setImageList(slideModels, ScaleTypes.FIT);`
    

    Failed to resolve transition , cardview , coordinatorlayout

    I got unresolved references when using the library with androidx and material component

    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.3.1'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.0'
    implementation 'androidx.activity:activity-ktx:1.2.0-alpha08'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    
    def lifecycle_version = "2.2.0"
    // ViewModel
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
    
    // slider
    implementation 'com.github.denzcoskun:ImageSlideshow:0.0.7'
    
    implementation 'com.google.android.material:material:1.0.0-rc01'
    implementation 'androidx.viewpager2:viewpager2:1.1.0-alpha01'
    implementation "androidx.coordinatorlayout:coordinatorlayout:1.1.0"   
    

    Slide listner

    Hello,
    Thank you for the library. I would like to ask is there any listener on change image or slide?

    Thanks in advance

    setItemClickListener

    not work in java code

    imageSliderAdvertisement.setItemClickListener(new ItemClickListener() {
    @OverRide
    public void onItemSelected(int i) {

            }
        });
    

    SetCurrentItem

    How to set imageSlider's viewpager currentItem programmatically?

    Title and Image

    Hello kardes, I want to delete title from the image and save only slides. How can I achieve that? Memnun olurum yardimci olursan

    Implement setOnTouchListener

    Hi,

    I' am trying to double click in the carousel image, but this doesn't work. Any idea how to fix this?My code:

    carousel.setOnTouchListener { _, motionEvent -> mDetector.onTouchEvent(motionEvent)

    Delay in Changing Image

    When the cursor moves to indicate the next image their is an unever delay between the transitions

    indicator

    if user want to change the indicator from center to left or right

    Pause auto sliding when touching image

    Hi guys,

    thanks Deniz for your simple and awesome slider,

    I want to pause the auto sliding until i release my finger of the slider, there is a way to do this with this lib??

    thanks

    not removed old list (multiple images -> single image)

    Hi
    I have a problem with setting images in ImageSlider

    when I set the new image list(single image) into the ImageSlider object that already has image list(multiple images), old list is still remained
    And also indicator dots are remained too

    my code just do when images are changed, create new array and add image URLs and set into the ImageSlider object
    Am I have to clear the ImageSlider's image list?

    I saw closed issue similar with me... but I think it's not fixed completely.. or my fault

    setItemClickListener not working

    Hello! Thanks for this amazing lib,

    I tried to add item click listener but it is not working!

    binding.homeSlider.setItemClickListener(object : ItemClickListener {
                override fun onItemSelected(position: Int) {
                    Log.i("slider","item selected $position")
                    Log.d("slider","slider value is null!")
                    vm.slider.value?.let {
                        val slider = it[position]
    
                        if (slider.category != "0"){
                            val products = homeToProducts(slider.category)
                            view?.let {
                                findNavController(it).navigate(products)
                            }
                        }
                        if (slider.sliderURL != "") {
                            val i = Intent(Intent.ACTION_VIEW)
                            i.data = Uri.parse(slider.sliderURL)
                            startActivity(i)
                        }
                    }
                }
            } )
    

    versiyon farkı

    Kardeşim selam
    Senin kütüphaneyi kullanıyordum 0.0.6 v ancak 0.0.7 deki özellikleri java da nasıl kullanacağım

    how to hide title section

    thanks for your great library
    is there anyway to remove the title part ?
    I need to remove the darkness of it on the slideshow .

    how can I do so ?

    Slide the image to a specific position

    Hello, thank you so much for the library. It is very handy and works well.
    Just wanted to know if there is any function currently to slide the image based on the position.

    For example, let's say I have added 5 images to SlideModel list. Now is there a way that from image1 I can programmatically shift to image4 in the slider.

    Hide indicator

    Hi! How I hide the indicator if we have a single image?

    AutoSlide control from code

    Hi, thanks for this library, easy to use and the default options work great for many cases.

    I have a an issue, i need a way to Start/stop the autoslide function but there is no func for that in your code, also a way to modify the period time of the autoslide.

    Also without this function I give this lib a Star, great work.

    Image Scaling Feture

    Hi, thank you so much for this library. I want to scale the imageview.
    How can I do? Can you add a feture?

    Set in java

    Hi, I have tried to set the slider in java instead of kotlin, but somehow it keeps crashing, is there a way to set it?

    getPlaceholderDrawable - java.lang.OutOfMemoryError

    I notice a crash on some devices. The error occurs in "getPlaceholderDrawable". I understand that there is not much you can do, if the device has too little memory, this is exactly the error. But i think the app should not crash is this case. This leads to a bad user experience and users will uninstall the app immediately.

    Please think about including this part in a try catch. Or pass the exception with @throws so we can catch it in our own code

    Fatal Exception: java.lang.OutOfMemoryError: Failed to allocate a 69310092 byte allocation with 4194304 free bytes and 44MB until OOM
           at dalvik.system.VMRuntime.newNonMovableArray(VMRuntime.java)
           at android.graphics.BitmapFactory.nativeDecodeAsset(BitmapFactory.java)
           at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:701)
           at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:508)
           at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:1152)
           at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:930)
           at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:769)
           at android.content.res.Resources.getDrawable(Resources.java:834)
           at android.content.Context.getDrawable(Context.java:529)
           at com.squareup.picasso.RequestCreator.getPlaceholderDrawable(RequestCreator.java:741)
           at com.squareup.picasso.RequestCreator.into(RequestCreator.java:701)
           at com.squareup.picasso.RequestCreator.into(RequestCreator.java:665)
           at com.denzcoskun.imageslider.adapters.ViewPagerAdapter.instantiateItem(ViewPagerAdapter.java:57)
           at com.denzcoskun.imageslider.adapters.ViewPagerAdapter.instantiateItem(ViewPagerAdapter.java:19)
           at androidx.viewpager.widget.ViewPager.addNewItem(ViewPager.java:1010)
           at androidx.viewpager.widget.ViewPager.populate(ViewPager.java:1158)
           at androidx.viewpager.widget.ViewPager.populate(ViewPager.java:1092)
           at androidx.viewpager.widget.ViewPager.onMeasure(ViewPager.java:1622)
           at android.view.View.measure(View.java:19931)
           at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:715)
           at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461)
           at android.view.View.measure(View.java:19931)
           at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:715)
           at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461)
           at android.view.View.measure(View.java:19931)
           at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6139)
           at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1485)
           at android.widget.LinearLayout.measureVertical(LinearLayout.java:775)
           at android.widget.LinearLayout.onMeasure(LinearLayout.java:657)
           at android.view.View.measure(View.java:19931)
           at android.widget.ScrollView.measureChildWithMargins(ScrollView.java:1330)
           at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
           at android.widget.ScrollView.onMeasure(ScrollView.java:352)
           at android.view.View.measure(View.java:19931)
           at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6139)
           at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1485)
           at android.widget.LinearLayout.measureVertical(LinearLayout.java:775)
           at android.widget.LinearLayout.onMeasure(LinearLayout.java:657)
           at android.view.View.measure(View.java:19931)
           at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6139)
           at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1485)
           at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:1134)
           at android.widget.LinearLayout.onMeasure(LinearLayout.java:659)
           at android.view.View.measure(View.java:19931)
           at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6139)
           at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
           at androidx.appcompat.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:146)
           at android.view.View.measure(View.java:19931)
           at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6139)
           at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1485)
           at android.widget.LinearLayout.measureVertical(LinearLayout.java:775)
           at android.widget.LinearLayout.onMeasure(LinearLayout.java:657)
           at android.view.View.measure(View.java:19931)
           at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6139)
           at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
           at android.view.View.measure(View.java:19931)
           at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6139)
           at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1485)
           at android.widget.LinearLayout.measureVertical(LinearLayout.java:775)
           at android.widget.LinearLayout.onMeasure(LinearLayout.java:657)
           at android.view.View.measure(View.java:19931)
           at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6139)
           at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
           at com.android.internal.policy.DecorView.onMeasure(DecorView.java:729)
           at android.view.View.measure(View.java:19931)
           at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2442)
           at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1488)
           at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1747)
           at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1372)
           at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6774)
           at android.view.Choreographer$CallbackRecord.run(Choreographer.java:926)
           at android.view.Choreographer.doCallbacks(Choreographer.java:735)
           at android.view.Choreographer.doFrame(Choreographer.java:667)
           at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:912)
           at android.os.Handler.handleCallback(Handler.java:761)
           at android.os.Handler.dispatchMessage(Handler.java:98)
           at android.os.Looper.loop(Looper.java:156)
           at android.app.ActivityThread.main(ActivityThread.java:6517)
           at java.lang.reflect.Method.invoke(Method.java)
           at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)
    

    ImageTitle

    can i center the title inside image ?

    Indicator Position change

    Thanks for this library. It works well. but I'm facing one problem I want to change the indicator gravity center to left. Is it possible when I use this library? Or else can I use custom or another library for the indicator only?

    java.lang.RuntimeException: Unable to start activity ComponentInfo{yodgorbek.komilov.musobaqayangiliklari/yodgorbek.komilov.musobaqayangiliklari.ui.SliderActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.denzcoskun.imageslider.ImageSlider.setImageList(java.util.List, boolean)' on a null object reference

    I am developing a news app and I am using your library but when I run the application I am getting the following exception

    java.lang.RuntimeException: Unable to start activity ComponentInfo{yodgorbek.komilov.musobaqayangiliklari/yodgorbek.komilov.musobaqayangiliklari.ui.SliderActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.denzcoskun.imageslider.ImageSlider.setImageList(java.util.List, boolean)' on a null object reference
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2976)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3113)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:113)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:71)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1858)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:201)
    at android.app.ActivityThread.main(ActivityThread.java:6820)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:922)
    Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.denzcoskun.imageslider.ImageSlider.setImageList(java.util.List, boolean)' on a null object reference
    at com.denzcoskun.imageslider.ImageSlider.setImageList$default(ImageSlider.kt:59)
    at yodgorbek.komilov.musobaqayangiliklari.ui.SliderActivity.onCreate(SliderActivity.kt:32)
    at android.app.Activity.performCreate(Activity.java:7224)
    at android.app.Activity.performCreate(Activity.java:7213)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2956)
    ... 11 more

    below my SliderActivity.kt

    class SliderActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_slider)
        val imageSlider = findViewById<ImageSlider>(R.id.image_slider)
        val imageList = ArrayList<SlideModel>()
        imageList.add(
            SlideModel(R.drawable.news, "Follow live news")
        )
        imageList.add(
            SlideModel(R.drawable.news_slider, "Follow live news")
        )
        imageList.add(
            SlideModel(R.drawable.news, "Follow live news")
        )
    
        imageSlider.setImageList(imageList, true)
    
    }
    

    }

    below my activity_slider.xml

    
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
    
        <com.denzcoskun.imageslider.ImageSlider
            android:id="@+id/image_slider"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    
    
    </LinearLayout>
    

    I am doing exactly as suggested in read me file

    Picture flips

    If show image big size, the library picture flips.

    It could be because of Picasso.

    Title text align

    Hi
    How can I use title align?
    center value for app:iss_text_align doesn't works for me

    OnClickListener

    Hi, how can i set up different tasks for every item on the clicklistener?

    Stop Image Auto Scaling

    Hello, Thanks for the wonderful library.
    I used this library for image slider and for product detail, this library perfectly feet for image slider in my case. however, I want to stop image auto-scaling on product view. how can I fix this? Thanks.

    Feature request

    Could you add a way to override 'loading' image too, please?

    Add and space between images

    Hi.
    First of all, thanks @denzcoskun for share with us your awesome ImageSlider.
    I´m trying to add and space between my images using Android Studio, the Slider looks fine, but I think if the images wasnt collapsed could be better.
    I tried some xml properties but didnt worked at the moment.
    Can you please help me with this?
    Thanks!

    Problem with RecyclerView

    Hello and thanks for this library. I have a problem with ImageSlider in a RecyclerView. The problem is when I put it in a RecyclerView when I scroll down and up when the view is being created for the second time, sometimes the timer will go dumb and starts changing the image fast like at 700 ms pace and it doesn't obey the "period" and "delay" that is given anymore.

    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.