自定义封装 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的贡献.当然了是英文版的,有文档就不错了.为了便于查阅和理解,我把之后陆续找…

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;再不可能去按照传统生产模式…

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利用的是程序的局部…

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判断, 判断一般起到控制作…

编程语言难度排名_谷歌排名第一的编程语言,小学生拿来做答题,分分钟钟搞定高难度算法!...

点击上方蓝色文字关注我们吧谷歌排名第一的编程语言时什么&#xff1f;毫无疑问&#xff1a;肯定是 Python。 也难怪&#xff0c;作为大数据时代和人工智能时代的必备语言&#xff0c;Python 的优点太多了&#xff0c;语言简洁、易学、开发效率高、可移植性强...... 另外&#…

【转载】fullpage.js学习

参考网址&#xff1a;http://www.dowebok.com/77.html 上面有详细介绍及案例展示&#xff0c;很不错哦&#xff0c;可以先去看看demo 一、简介 fullPage.js 是一个基于jQuery的插件&#xff0c;它能够很方便、很轻松的制作出全屏网站&#xff0c;主要功能有&#xff1a; 1.支持…

webpack打包测试_webpack入门笔记(一)

webpack 是一个现代 JavaScript 应用程序的静态模块打包器(module bundler)。当 webpack 处理应用程序时&#xff0c;它会递归地构建一个依赖关系图(dependency graph)&#xff0c;其中包含应用程序需要的每个模块&#xff0c;然后将所有这些模块打包成一个或多个 bundle。webp…

mysql中的内置函数

mysql内置函数列表可以从mysql官方文档查询&#xff0c;这里仅分类简单介绍一些可能会用到的函数。 1 数学函数 abs(x) pi() mod(x,y) sqrt(x) ceil(x)或者ceiling(x) rand(),rand(N):返回0-1间的浮点数&#xff0c;使用不同的seed N可以获得不同的随机数 round(x, D)&#xff…

使用 sitemesh/decorator装饰器装饰jsp页面(原理及详细配置)

摘要&#xff1a;首先这个Decorator解释一下这个单词&#xff1a;“装饰器”&#xff0c;我觉得其实可以这样理解&#xff0c;他就像我们用到的Frame&#xff0c;他把每个页面共有的东西提炼了出来&#xff0c;也可能我们也会用各种各样的include标签&#xff0c;将我们的常用页…

安卓开发 新浪微博share接口实现发带本地图片的微博

1.微博share接口 在开始之前&#xff0c;我们先看一下要用到的这个接口&#xff1a; 我们这次是要上传本地图片&#xff0c;可以很明确的知道&#xff0c;除了要用POST方式提交请求&#xff0c;还要采用multipart/form-data编码方式。 那么这个multipart/form-data编码方式是什…

VirtualBox安装Centos6.8出现——E_INVALIDARG (0x80070057)

VirtualBox使用已有的虚拟硬盘出错&#xff1a; 问题描述&#xff1a;UUID已经存在 Cannot register the hard disk E:\system_iso\centos6.8.vdi {05f096aa-67fc-4191-983d-1ed00fc6cce9} because a hard disk E:\system_iso\centos68_02\centos6.8.vdi with UUID {05f096aa-6…

非线性动力学_非线性动力学特辑 低维到高维的联通者

序言&#xff1a; 本文将以维度为主线&#xff0c; 带量大家进入非线性动力学的世界。 文章数学部分不需要全部理解&#xff0c; 理解思维方法为主非线性动力学&#xff0c;是物理学的思维进入传统方法所不能解决的问题的一座丰碑。它可以帮助我们理解不同复杂度和时间空间尺度…

成本预算的四个步骤_全网推广步骤有哪些?

全网推广的步骤是什么&#xff1f;一般来说&#xff0c;搜索引擎优化是大多数中小企业常用的推广方法。主要是通过对一些搜索引擎的排名来提高网站的曝光率&#xff0c;从而更好的提高自己网站的流量&#xff0c;从而更好的实现互联网层面的销售。接下来&#xff0c;让我们学习…

python生成requirements.txt的两种方法

python项目如何在另一个环境上重新构建项目所需要的运行环境依赖包&#xff1f; 使用的时候边记载是个很麻烦的事情&#xff0c;总会出现遗漏的包的问题&#xff0c;这个时候手动安装也很麻烦&#xff0c;不能确定代码报错的需要安装的包是什么版本。这些问题&#xff0c;requi…

node.js 安装使用http-server

node.js npm全局安装了http-server后我该怎么使用它&#xff1f;我在它的安装目录下创建了inde.html&#xff0c;浏览器localhost:8080可以访问&#xff0c;那我的项目需要放在它的安装目录下&#xff1f;还是需要在我的项目下配置什么或者使用什么指令启动它&#xff1f;我在我…