Giter VIP home page Giter VIP logo

sliderlayout's Introduction

SliderLayout

SliderLayout 是一款自定义的无限自动轮播滚动控件,可以实现类似于京东淘宝的广告轮播效果。

SliderLayout 具有以下的功能。

1、可以自定义滚动指示器的样式,扩展性强。

2、同时支持网络图片以及资源图片的加载和显示。

3、可以自定义控制滚动的时间、是否开启自动轮播等属性。

4、使用 Picasso 加载图片,同时显示图片的加载提示。

5、图片的事件监听等均可以扩展。

Gradle

1、在 Project 的 build.gradle 文件中添加配置,已经发布到 Jcenter,所以只要配置 jcenter 就可以了。

allprojects {
    repositories {
        jcenter()
    }
}

2、在 module 下的 build.gradle 文件中添加依赖。

compile 'com.liuting.sliderlayout:SliderLayout:1.0.1'

About

1、在布局文件 layout 中写入。

<com.liuting.sliderlayout.SliderLayout
    android:id="@+id/main_layout_jingdong"
    android:layout_width="match_parent"
    android:layout_height="200dp"
    android:background="@android:color/white"
    app:sl_default_image="@mipmap/ic_default"
    app:sl_indicator_margin="6dp"
    app:sl_indicator_position="centerBottom"
    app:sl_indicator_shape="oval"
    app:sl_indicator_space="3dp"
    app:sl_selected_indicator_color="@android:color/white"
    app:sl_selected_indicator_height="6dp"
    app:sl_selected_indicator_width="6dp"
    app:sl_unselected_indicator_color="@color/unselected_color"
    app:sl_unselected_indicator_height="6dp"
    app:sl_unselected_indicator_width="6dp"
    app:sl_arc_height="0dp"
    ></com.liuting.sliderlayout.SliderLayout>

2、在 Activity/Fragment 中直接声明使用。

SliderLayout layoutImage = (SliderLayout) findViewById(R.id.main_layout_jingdong);
//设置Dialog提示框样式,用于加载网络图片时进度提示
layoutImage.setLoadingDialog(dialog);
//添加图片的点击事件
layoutImage.setListener(new SliderLayout.IOnClickListener() {
        @Override
        public void onItemClick(View view, int position) {
            Toast.makeText(MainActivity.this,"第 "+(position+1)+" 张图片",Toast.LENGTH_SHORT).show();
        }
    });

3、如果开启了自动滚动的话,在 Activity/Fragment 生命周期 Destroy 的时候记得停止自动滚动。

@Override
protected void onStop() {
    layoutImage.stopAutoPlay();
    layoutImage.dismissDialog();
    super.onStop();
}

4、参考Demo: https://github.com/LT5505/SliderLayout/tree/master/app

5、博客详细介绍:http://www.cnblogs.com/LT5505/p/6652449.html

6、效果图

效果图

效果图

效果图

最后,感谢开源 https://github.com/dongjunkun/BannerLayouthttps://github.com/florent37/ArcLayout

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.