自定義封裝 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.pswp.cn/news/455331.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/455331.shtml
英文地址,請注明出處:http://en.pswp.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判斷, 判斷一般起到控制作…