自定义封装 banner 组件

1. 效果图预览

 

 

2.基本功能

一个简单方便的轮播图组件,基于viewpager 基础上进行的封装。
可设置 项目中图片,网络图片, View;
支持循环自动播放,手势滑动切换,item点击事件,可设置 点点的样式宽高、颜色、大小、位置 ,;
可设置蒙层;可设置 是否允许滑动;可设置 是否允许循环。

 

3.基本实现

1. 自定义属性

    <declare-styleable name="BannerLayoutStyle"><attr name="maskStartColor" format="color|reference" /><attr name="maskEndColor" format="color|reference" /><attr name="selectedIndicatorColor" format="color|reference" /><attr name="unSelectedIndicatorColor" format="color|reference" /><attr name="indicatorShape" format="enum"><enum name="rect" value="0" /><enum name="oval" value="1" /></attr><attr name="selectedIndicatorHeight" format="dimension|reference" /><attr name="selectedIndicatorWidth" format="dimension|reference" /><attr name="unSelectedIndicatorHeight" format="dimension|reference" /><attr name="unSelectedIndicatorWidth" format="dimension|reference" /><attr name="indicatorPosition" format="enum"><enum name="centerBottom" value="0" /><enum name="rightBottom" value="1" /><enum name="leftBottom" value="2" /><enum name="centerTop" value="3" /><enum name="rightTop" value="4" /><enum name="leftTop" value="5" /></attr><attr name="indicatorSpace" format="dimension|reference" /><attr name="indicatorMargin" format="dimension|reference" /><attr name="autoPlayDuration" format="integer|reference" /><attr name="scrollDuration" format="integer|reference" /><attr name="isAutoPlay" format="boolean" /><attr name="defaultImage" format="integer|reference" /><attr name="isIndicatorVisible" format="boolean" /><attr name="cornerRadii" format="dimension|reference" /></declare-styleable>

2.基本方法

    //添加本地图片路径public void setViewRes(List<Integer> viewRes) {。。。}//添加网络图片路径public void setViewUrls(List<String> urls) {。。。}//添加任意View视图private void setViews2(final List<View> views) {。。。}
    // 设置是否允许 循环public void setLoop(boolean loop) {}// 设置是否可以滑动public void setSlideable(boolean slideable) {}

更多用法 详见代码,这里就不全部粘贴了。

 3.使用示例:

<com.dzq.widget.CustomBannerViewandroid:id="@+id/banner"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_weight="1"app:autoPlayDuration="2000"app:defaultImage="@drawable/bg_banner"app:indicatorMargin="@dimen/indicatorMargin"app:indicatorPosition="rightBottom"app:indicatorShape="oval"app:indicatorSpace="@dimen/indicatorSpace"app:isAutoPlay="true"app:isIndicatorVisible="true"app:scrollDuration="1000"app:selectedIndicatorColor="@color/color_ec407a"app:selectedIndicatorHeight="5dp"app:selectedIndicatorWidth="5dp"app:unSelectedIndicatorColor="@color/color_71d9e7"app:unSelectedIndicatorHeight="5dp"app:unSelectedIndicatorWidth="5dp"/><com.dzq.widget.CustomBannerViewandroid:id="@+id/banner2"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="5dp"android:layout_weight="1"app:autoPlayDuration="2000"app:defaultImage="@drawable/bg_banner"app:indicatorMargin="@dimen/indicatorMargin"app:indicatorPosition="rightBottom"app:indicatorShape="rect"app:indicatorSpace="@dimen/indicatorSpace"app:isAutoPlay="false"app:isIndicatorVisible="true"app:scrollDuration="1000"app:selectedIndicatorColor="@color/color_ec407a"app:selectedIndicatorHeight="5dp"app:selectedIndicatorWidth="10dp"app:unSelectedIndicatorColor="@color/color_71d9e7"app:unSelectedIndicatorHeight="10dp"app:unSelectedIndicatorWidth="5dp"/><com.dzq.widget.CustomBannerViewandroid:id="@+id/banner3"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="5dp"android:layout_weight="1"app:cornerRadii="5dp"app:indicatorMargin="@dimen/indicatorMargin"app:indicatorPosition="centerTop"app:indicatorShape="rect"app:indicatorSpace="@dimen/indicatorSpace"app:isAutoPlay="false"app:isIndicatorVisible="true"app:maskEndColor="#00000000"app:maskStartColor="#99000000"app:scrollDuration="1000"app:selectedIndicatorColor="#00CAA9"app:selectedIndicatorHeight="10dp"app:selectedIndicatorWidth="25dp"app:unSelectedIndicatorColor="#26000000"app:unSelectedIndicatorHeight="10dp"app:unSelectedIndicatorWidth="10dp" />

 

项目源码下载

导入自己项目

How to

To get a Git project into your build:

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.dingzuoqiang:CustomBannerView:v1.0'}

 

转载于:https://www.cnblogs.com/dingzq/p/7085944.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/455331.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

vb.net服务器启动后cpu占用了70_记一次服务器被异常程序占用的解决过程(怀疑黑客攻击)...

最近在跑实验&#xff0c;但是突然发现程序运行变慢&#xff0c;然后top命令查看程序运行情况&#xff0c;发现有异常进程&#xff0c;名字叫 bash&#xff0c;占用 2400% CPU计算资源。刚开始怀疑是挖矿程序&#xff0c;因实验室网络IP为教育网公网&#xff0c;怀疑被攻击&…

3gp文件格式研究 (转windcao的专栏)

序言 06我开始做3gp文件的播放器,但是关于3gp的文档太少了也很难找,在网友luxh的帮助下,我终于有了第一份关于3gp文件格式的文档《ISO/IEC 14496-12&#xff0c;ISO媒体文件格式》.在此真心感谢luxh的贡献.当然了是英文版的,有文档就不错了.为了便于查阅和理解,我把之后陆续找…

Android开发必用工具及其进阶途径

三百六十行&#xff0c;行行出状元&#xff0c;怎么样才能在Android行业中当个状元了&#xff0c;开发过程中的高效、自我能力的提升显得至关重要&#xff0c;步入IT行业更是要时时刻刻学习&#xff0c;新技术更新快&#xff0c;今天将介绍一下Android开发中必用工具及其进阶途…

MySQL遇到check the manual that corresponds to your MySQL server version for the right syntax错误

原来是MySQL表中不能包含关键字 转载于:https://www.cnblogs.com/flycoding/p/7088465.html

Python脚本实现图片加水印

起步 图片是指由图形、图像等构成的平面媒体,有形式的事物&#xff0c;我们看到的&#xff0c;是图画、照片、拓片等的统称。 为了保护一些原创图片的版权,某些时候我们需要在图片上面,加上水印,当然你可以用Photoshop来做,只不过如果图片数量过多,亦或者图片的动态生成的时候…

yarn 怎么查看有多个job在跑_flink on yarn 模式下提示yarn资源不足问题分析

背景在实时计算平台上通过YarnClient向yarn上提交flink任务时一直卡在那里&#xff0c;并在client端一直输出如下日志&#xff1a;(YarnClusterDescriptor.java:1036)- Deployment took more than 60 seconds. Please check if the requested resources are available in the Y…

MPEG-2TS码流编辑的原理及其应用(转载

[作者&#xff1a;辽宁电视台 赵季伟] 在当今数字媒体不断发展、新媒体业务不断涌现 的前提下&#xff0c;实践证明襁褓中的新媒体只有两种经营方略可供选择&#xff1a;或是购买并集成整套节目&#xff0c;或是低成本深加工新节目&#xff0c;再不可能去按照传统生产模式…

Python中的yield详解

阅读别人的python源码时碰到了这个yield这个关键字&#xff0c;各种搜索终于搞懂了&#xff0c;在此做一下总结&#xff1a; 通常的for…in…循环中&#xff0c;in后面是一个数组&#xff0c;这个数组就是一个可迭代对象&#xff0c;类似的还有链表&#xff0c;字符串&#xf…

shell循环结构之while循环

while循环 1) while CONDITION; dostatementstatement<改变循环条件真假的语句>done 编写脚本&#xff0c;计算1---100的和 #!/bin/bash#sum0i1while [ $i -le 100 ]; dolet sum$sum$ilet i$i1doneecho $sum2) while true; do statementstatementdone #!/bin/bash#while …

python 管道队列_关于python:Multiprocessing-管道与队列

Python的多处理程序包中的队列和管道之间的根本区别是什么&#xff1f;在什么情况下应该选择一种&#xff1f; 什么时候使用Pipe()有优势&#xff1f; 什么时候使用Queue()有优势&#xff1f;Pipe()只能有两个端点。Queue()可以有多个生产者和消费者。何时使用它们如果需要两个…

pip默认使用国内镜像地址

很多小伙伴在ubuntu系统下,使用pip安装会很慢 以为安装源在国外服务器上面 今天小编就教大家配置成让pip默认从国内源中寻找安装包 首先CtrlAltT打开终端 进入家目录 cd ~在家目录中创建一个文件夹,命名为.pip mkdir .pip进入目录,并创建一个名为pip.conf的文件 cd .pip…

“大型票务系统”和“实物电商系统”的数据库选型

讨论请移步至&#xff1a;http://www.zhiliaotech.com/ideajam/idea/detail/423 相关文章&#xff1a; 《今天你买到票了吗&#xff1f;——从铁道部12306.cn站点漫谈电子商务站点的“海量事务快速处理”系统》 不能简单套用“实物电商系统”对“大型票务系统”做需求分析 “大…

FLV文件格式(Z)(转载)

刚才在看一些关于demux的东西&#xff0c;在处理flv格式的文件的时候&#xff0c;由于自己对flv文件的格式不了解&#xff0c;所以就比较云头转向&#xff0c;正好看到了一篇讲述flv文件格式的文章&#xff0c;写的比较明白&#xff0c;所以就转过来了。O(∩_∩)O~flv头文件比较…

mysql-5.7中的innodb_buffer_pool_prefetching(read-ahead)详解

一、innodb的read-ahead是什么&#xff1a; 所谓的read-ahead就是innodb根据你现在访问的数据&#xff0c;推测出你接下来可能要访问的数据&#xff0c;并把它们(可能要访问的数据)读入 内存。 二、read-ahead是怎么做到的&#xff1a; 1、总的来说read-ahead利用的是程序的局部…

python compare excel_python简单操作excle的方法

Python操作Excle文件&#xff1a;使用xlwt库将数据写入Excel表格&#xff0c;使用xlrd 库从Excel读取数据。从excle读取数据存入数据库1、导入模块&#xff1a;import xlrd2、打开excle文件&#xff1a;data xlrd.open_workbook(excel.xls)3、获取表、行/列值、行/列数、单元值…

collections系列

class Counter(dict):  Counter类继承dict类、继承了dict的所有功能计数器&#xff1a; 例&#xff1a;import collections obj collections.Counter(sdkasdioasdjoasjdoasd) print(obj)得&#xff1a;Counter({s: 5, d: 5, a: 4, o: 3, j: 2, k: 1, i: 1}) 拿到前几位&…

Python中的虚拟环境-virtualenv

更低层次: virtualenv virtualenv 是一个创建隔绝的Python环境的 工具。virtualenv创建一个包含所有必要的可执行文件的文件夹&#xff0c;用来使用Python工程所需的包。 它可以独立使用&#xff0c;代替Pipenv。 通过pip安装virtualenv&#xff1a; $ pip install virtual…

mp4文件格式解析(一)

原文地址&#xff1a;mp4文件格式解析&#xff08;一&#xff09;作者&#xff1a;可下人间目前MP4的概念被炒得很火&#xff0c;也很乱。最开始MP4指的是音频&#xff08;MP3的升级版&#xff09;&#xff0c;即MPEG-2 AAC标准。随后MP4概念被转移到视频上&#xff0c;对应的是…

shiro身份验证测试

2019独角兽企业重金招聘Python工程师标准>>> 一、登录验证 1、首先在shiro.ini里准备一些用户身份/凭据&#xff0c;后面这里会使用数据库代替&#xff0c;如&#xff1a; [users] [main] #realm jdbcRealmcom.learnging.system.shiro.ShiroRealm securityManager…

shell if多个条件判断_萌新关于Excel VBA中IF条件判断语句的一点心得体会

作者:金人瑞 《Excel VBA175例无理论纯实战教程》学员最近正在学习郑广学老师的VBA 175例教程&#xff0c;这是一篇新手向的文章&#xff0c;也是一个新手的总结&#xff0c;高手可以批评文章中的不足之处&#xff0c;也可以无视&#xff0c;VBA中的IF判断, 判断一般起到控制作…