国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Android > 正文

Android自定義封裝banner組件

2019-12-12 02:34:25
字體:
來源:轉載
供稿:網友

自定義封裝 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.CustomBannerView  android: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.CustomBannerView  android: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.CustomBannerView  android: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'}

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 富蕴县| 湘西| 浠水县| 瑞丽市| 虎林市| 英德市| 公主岭市| 大庆市| 海南省| 达日县| 崇州市| 南涧| 塔河县| 泰安市| 秦皇岛市| 滨州市| 靖西县| 陆河县| 崇文区| 平原县| 尼勒克县| 阿克陶县| 杭锦后旗| 谷城县| 谢通门县| 永川市| 甘洛县| 潼南县| 武宣县| 商丘市| 宜宾市| 莱西市| 延安市| 哈巴河县| 蓬溪县| 平武县| 承德县| 丰顺县| 神农架林区| 平度市| 通榆县|