Skip to content
프로젝트

소개

Banner Slider는 Android 앱에 이미지 슬라이더를 구현할 수 있는 사용하기 쉬운 라이브러리입니다.

디자인 및 미디어

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
-1
in 15 days
-1
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

Deprecated

I created this project in 2016. many things have changed and there are many other new great alternatives for creating sliders in android. so I decided to deprecate banner-slider.

Banner-Slider

Banner slider is an easy to use library for making beautiful sliders in your android app.

How to download

Gradle

add this line to your module build.gradle dependecies block:

compile 'com.ss.bannerslider:bannerslider:2.0.0'

Maven

<dependency>
  <groupId>com.ss.bannerslider</groupId>
  <artifactId>bannerslider</artifactId>
  <version>2.0.0</version>
  <type>pom</type>
</dependency>

How use this library

XML

<ss.com.bannerslider.Slider
   android:id="@+id/banner_slider1"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   />

Java

Step 1: extend SliderAdapter

in first step you must create an adapter to adapt your data model with slides. example implemented adapter with 3 slides:

public class MainSliderAdapter extends SliderAdapter {

    @Override
    public int getItemCount() {
        return 3;
    }

    @Override
    public void onBindImageSlide(int position, ImageSlideViewHolder viewHolder) {
        switch (position) {
            case 0:
                viewHolder.bindImageSlide("https://assets.materialup.com/uploads/dcc07ea4-845a-463b-b5f0-4696574da5ed/preview.jpg");
                break;
            case 1:
                viewHolder.bindImageSlide("https://assets.materialup.com/uploads/20ded50d-cc85-4e72-9ce3-452671cf7a6d/preview.jpg");
                break;
            case 2:
                viewHolder.bindImageSlide("https://assets.materialup.com/uploads/76d63bbc-54a1-450a-a462-d90056be881b/preview.png");
                break;
        }
    }
}

Step 2: specify your image loading service

you must specify image loading service for loading images(for better flexibility and prevent adding unnecessary libraries). for example if you work with picasso for loading images in your project, you must implement ImageLoadingService interface like below:

public class PicassoImageLoadingService implements ImageLoadingService {
    public Context context;

    public PicassoImageLoadingService(Context context) {
        this.context = context;
    }

    @Override
    public void loadImage(String url, ImageView imageView) {
        Picasso.with(context).load(url).into(imageView);
    }

    @Override
    public void loadImage(int resource, ImageView imageView) {
        Picasso.with(context).load(resource).into(imageView);
    }

    @Override
    public void loadImage(String url, int placeHolder, int errorDrawable, ImageView imageView) {
        Picasso.with(context).load(url).placeholder(placeHolder).error(errorDrawable).into(imageView);
    }
}

Step 3: initialize slider in your Application class

Slider.init(YOUR IMAGE LOADING SERVICE);

Step 4: set your adapter on slider

slider = findViewById(R.id.banner_slider1);
        slider.setAdapter(new MainSliderAdapter());

You want more customization?

Changing slides automatically in specifed periods

interval attribute get miliseconds.

  app:slider_interval="5000"

Loop slides

  app:slider_loopSlides="true"

Choose default banner to show up first

slider.setSelectedSlide(2);

you must pass banner position to it:

  app:slider_defaultBanner="1"

Enable/disable indicators animations

in default, animations are enabled

  app:slider_animateIndicators="true"

Use custom Indicators

if you also set default indicators, then this attributes will ignored

  app:slider_selectedSlideIndicator="@drawable/selected_slide_indicator"
  app:slider_unselectedSlideIndicator="@drawable/unselected_slide_indicator"

How set empty view, when banners not received from server yet?

  app:slider_emptyView="@layout/layout_empty_view"

Change indicator sizes

  app:slider_indicatorSize="12dp"

Set OnBannerClickListener

slider.setOnSlideClickListener(new OnSlideClickListener() {
            @Override
            public void onSlideClick(int position) {
                //Do what you want
            }
        });
  });

Licence

Copyright 2016 Saeed Shahini

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

http://www.apache.org/licenses/LICENSE-2.0

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.

Author

Saeed shahini

email: [email protected]

github: https://github.com/saeedsh92

관련 프로젝트 살펴보기

불러오는 중…