Skip to content

image switcher but, image switched automatically given interval

License

Notifications You must be signed in to change notification settings

JeonK1/BannerImageSwitcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BannerImageSwitcher

This is image banner library for easy to set image list and get functions that switch image to next, prev page and automatically switch next page.

  • minSdkVersion : BannerImageSwitcher requires a minimum SDK API level of 21.
  • Compile Android SDK : BannerImageSwitcher requires a compile SDK API level of 26 or later.

Notice: This Library is not zero dependency, it has Glide dependency for can set image list by url string list.


Quick Start

Setup

1. Add it in your build.gradle(Project) at the end of repositories

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

2. Add the dependency in your build.gradle(app)

	dependencies {
		implementation 'com.github.JeonK1:BannerImageSwitcher:1.0.1'
	}



How to use

1. you can define BannerImageSwitcher Widget in your layout xml files.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <com.example.bannerimageswitcher.BannerImageSwitcher
        android:id="@+id/banner_image_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"/>

</RelativeLayout>

2-1. you can set imageList by R.drawable.~~~ with .setImageList(resIds: List) function in your activity or fragments

        // image list with R.drawable directories
        val imageList = arrayListOf(
            R.drawable.first_image,
            R.drawable.second_image,
            R.drawable.third_image
        )

        banner_image_view.setImageList(imageList)

2-2. you can also set imageList by URI strings with .setImageList(urls: List) function in your activity or fragments

        // image list with R.drawable directories
        val imageList = arrayListOf(
            "https://dimg.donga.com/wps/NEWS/IMAGE/2019/10/13/97852357.2.jpg",
            "https://i.ytimg.com/vi/jyBbnSZFLh8/hqdefault.jpg"
        )
        
        banner_image_view.setImageList(imageList)

3. you can set image switch interval with .setInterval(msec: Long) function in your activity or fragments

        val banner_image_view = findViewById<BannerImageSwitcher>(R.id.banner_image_view);
        banner_image_view.setInterval(1000L)

4. you can set left/right button image with .setLeftButtomImageResource(resId: Int), .setRightButtomImageResource(resId: Int) function in your activity or fragments

        val banner_image_view = findViewById<BannerImageSwitcher>(R.id.banner_image_view);
        banner_image_view.setLeftButtomImageResource(R.drawable.ic_arrow_left)
        banner_image_view.setRightButtomImageResource(R.drawable.ic_arrow_right)



Example

switch to next image automatically every 10sec



switch to next image and prev image with button click



recount switch timer(set every 10sec) if click prev or next button





Development Note (Language: Korean)

About

image switcher but, image switched automatically given interval

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages