fork 自 AndroidImageSlider,用 fresco 改写,并增加动态刷新轮播图数据的方法

来源:互联网 发布:淘宝手机视频尺寸大小 编辑:程序博客网 时间:2024/04/20 04:42

ImageSliderByFresco

项目地址:ImageSliderByFresco
简介:fork 自 AndroidImageSlider,用 fresco 改写,并增加动态刷新轮播图数据的方法

说明

本项目 fork 自 https://github.com/daimajia/AndroidImageSlider

对其进行一些改写:

图片加载组件改成 fresco.

Sliderlayout 增加动态更新的方法:用于设置数据和刷新数据

refreshSlider(List<SliderInfo> datas, BaseSliderView.OnSliderClickListener listener)

设置图片大小(用于服务器压缩和向下采样)

public void setImageDimension(int width,int height)

解决了多次调用 startAutoCycle() 出现快速滚动两页的 bug

原说明

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


Usage

Step 1

gradle

Step 1. Add the JitPack repository to your build file

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 {        compile 'com.github.hss01248:ImageSliderByFresco:1.0.2'        compile 'com.daimajia.androidanimations:library:1.0.3@aar'        compile 'com.facebook.fresco:fresco:0.10.0'        compile 'com.facebook.fresco:animated-webp:0.10.0'        compile 'com.facebook.fresco:animated-gif:0.10.0'}

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" />

Step 3

Add the Slider to your layout:

<com.hss01248.slider.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.hss01248.slider.Indicators.PagerIndicator        android:id="@+id/custom_indicator"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:gravity="center"        />

Step 4 使用封装好的刷新方法

添加和刷新数据:

refreshSlider(List<SliderInfo> datas, BaseSliderView.OnSliderClickListener listener)

暂停和恢复轮播

startAutoCycle() stopAutoCycle()

Advanced usage

自定义动画,点的位置:

请看 demo 中的 MainActivity

Thanks

  • AndroidImageSlider

0 0
原创粉丝点击