All Projects → kongzue → FastBanner

kongzue / FastBanner

Licence: other
🔥快速轮播图,支持自定义布局和使用自有图片显示组件

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to FastBanner

Bannerlayout
Support unlimited picture rotation BannerLayout, the minimum implementation of the code banner
Stars: ✭ 92 (+240.74%)
Mutual labels:  view, layout, banner, viewpager
ViewWorld
自定义View合集,展示各种自定义View/控件。项目包含了自定义Banner轮播图控件,自定义验证码输入框,自定义TabLayout等控件,持续更新中😉😉😉
Stars: ✭ 94 (+248.15%)
Mutual labels:  view, banner, viewpager
Banner
🔥🔥ViewPager,ViewPager2无限轮播功能。自定义Indicator,支持一屏三页,支持仿魅族banner效果。极其简单的使用方式
Stars: ✭ 393 (+1355.56%)
Mutual labels:  view, banner, viewpager
Candyview
Implement any RecyclerView in just 1 Line. CandyView handles everything for you.
Stars: ✭ 15 (-44.44%)
Mutual labels:  fast, view
Revealbanner
🚀🚀🚀 滑动特效banner
Stars: ✭ 209 (+674.07%)
Mutual labels:  view, banner
Flexml
🚀基于Litho的Android高性能动态业务容器。
Stars: ✭ 225 (+733.33%)
Mutual labels:  view, layout
Android Statefullayout
A custom Android ViewGroup to display different states of screen (CONTENT, PROGRESS, OFFLINE, EMPTY, etc.)
Stars: ✭ 140 (+418.52%)
Mutual labels:  view, layout
ShadowDrawable
为View 和 ViewGroup 添加阴影效果--Android,Add shadow for single view or viewgroup layout.
Stars: ✭ 22 (-18.52%)
Mutual labels:  view, layout
SimpleSlider
A simple slider allows you to easily use.
Stars: ✭ 78 (+188.89%)
Mutual labels:  banner, viewpager
IndicatorView
IndicatorView Library For Android
Stars: ✭ 41 (+51.85%)
Mutual labels:  view, viewpager
AutoScrollLoopViewPager
AutoScrollLoopViewPager, 无限轮播的Banner
Stars: ✭ 46 (+70.37%)
Mutual labels:  banner, viewpager
Android 3d Layout
Wow effect, transform your layout into 3D views
Stars: ✭ 199 (+637.04%)
Mutual labels:  view, layout
Expansionpanel
Android - Expansion panels contain creation flows and allow lightweight editing of an element.
Stars: ✭ 1,984 (+7248.15%)
Mutual labels:  view, layout
Cardslider
Card Slider is an android component allows you to implement carousel effect with infinite indicators and more features
Stars: ✭ 160 (+492.59%)
Mutual labels:  view, viewpager
FillProgressLayout
A simple and flexible Fillable Progress Layout written in Kotlin
Stars: ✭ 77 (+185.19%)
Mutual labels:  view, layout
LoopBanner
一个简单好用且超轻量的自动轮播控件,支持UI风格完全自定义
Stars: ✭ 56 (+107.41%)
Mutual labels:  banner, viewpager
pulldownlayout
PullDownLayout is a small library that allows you to implement a view that can be dragged down your layout. PullDownLayout can also be used to implement Pull-To-Dismiss feature for your activities and fragments.
Stars: ✭ 16 (-40.74%)
Mutual labels:  view, layout
table-layout
Styleable plain-text table generator. Useful for formatting console output.
Stars: ✭ 18 (-33.33%)
Mutual labels:  view, layout
Arclayout
With Arc Layout explore new styles and approaches on material design
Stars: ✭ 1,662 (+6055.56%)
Mutual labels:  view, layout
DynamicViewPagerDemo
ViewPager单屏显示多页面,动画效果
Stars: ✭ 49 (+81.48%)
Mutual labels:  view, viewpager

Kongzue FastBanner

Kongzue FastBanner是一款快速创建轮播图的组件,仅需要简单配置即可满足绝大多数需要使用轮播图的场景。

Kongzue Tabbar Maven License Homepage

Demo预览图如下:

FastBanner

Demo下载地址:

点击下载

优势

  • 快速实现,无需复杂配置,满足绝大多数轮播场景;

  • 提供可定制化子界面的轮播,应对相对复杂的场景;

使用方法

  1. 从 Maven 仓库或 jCenter 引入: Maven仓库:
<dependency>
  <groupId>com.kongzue.banner</groupId>
  <artifactId>basebanner</artifactId>
  <version>1.0.4</version>
  <type>pom</type>
</dependency>

Gradle: 在dependencies{}中添加引用:

implementation 'com.kongzue.banner:basebanner:1.0.4'
  1. 从XML布局文件创建:
<com.kongzue.basebanner.SimpleBanner xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/simpleBanner"
    android:layout_width="match_parent"
    android:layout_height="200dp"
    app:indicatorVisibility="true"
    app:indicatorNormal="@drawable/rect_white_alpha50"
    app:indicatorFocus="@drawable/rect_white_alpha90"
    app:indicatorGravity="center">
</com.kongzue.basebanner.SimpleBanner>

其中各属性解释如下:

字段 含义 默认值
indicatorVisibility 是否显示指示器 true
indicatorNormal 指示器普通情况下的样式 半透明白色小圆点(R.drawable.rect_white_alpha50)
indicatorFocus 指示器焦点情况下的样式 白色小圆点(R.drawable.rect_white_alpha90)
indicatorGravity 指示器所处位置 默认center(可选left, center, right)
indicatorMargin 指示器到边框的距离 15dp
delay 自动轮播延迟 4000毫秒
period 自动轮播周期 4000毫秒
autoPlay 自动播放 true
  1. 代码中设置要轮播的数据

FastBanner 并不自带图片显示框架,您可以自行选择 Fresco、Glide 或其他框架。

FastBanner 要通过代码来设置轮播数据,方法很简单,这里以 Fresco 举例:

//准备你的数据
List<String> imageUrls = new ArrayList<>();
imageUrls.add("http://example.com/test/fs/1.jpg");
imageUrls.add("http://example.com/test/fs/2.jpg");
imageUrls.add("http://example.com/test/fs/3.jpg");

//绑定数据
simpleBanner.setData(imageUrls, new SimpleBanner.BindData<SimpleDraweeView>(){
    @Override
    public void bind(String url, SimpleDraweeView imageView, int index) {
        imageView.setImageURI(url);
    }
});

代码中的接口 BindData 是用于绑定你的图片组件和内容的,它可以设置一个泛型,来确定你所使用的图片组件。

另外请注意检查你的网络访问权限,很多情况下无法显示轮播图内容的原因是因为未声明网络权限。

自定义布局的 CustomBanner

偶尔我们需要 Banner 的内容布局中添加一些动态文本,或者其他东西,此时可以使用 CustomBanner 来实现:

  1. 从XML布局文件创建 CustomBanner:
<com.kongzue.basebanner.CustomBanner xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/customBanner"
    android:layout_width="match_parent"
    android:layout_height="200dp"
    app:indicatorVisibility="true"
    app:indicatorNormal="@drawable/rect_white_alpha50"
    app:indicatorFocus="@drawable/rect_white_alpha90"
    app:indicatorGravity="right">
</com.kongzue.basebanner.CustomBanner>
  1. 准备一个内容布局 item_banner.xml

可查看:范例代码

  1. 使用代码创建并绑定数据
//准备你的数据
List<Map<String,Object>> bannerData = new ArrayList<>();
Map<String,Object> data = new HashMap<>();
data.put("title","场馆标题A");
data.put("tip","北京市朝阳区某某东大街135号");
data.put("tip2","距离500M 1680人光顾");
data.put("img","http://example.com/test/fs/1.jpg");
bannerData.add(data);
data = new HashMap<>();
data.put("title","场馆标题B");
data.put("tip","北京市朝阳区某某东大街135号");
data.put("tip2","距离500M 1680人光顾");
data.put("img","http://example.com/test/fs/2.jpg");
bannerData.add(data);
data = new HashMap<>();
data.put("title","场馆标题C");
data.put("tip","北京市朝阳区某某东大街135号");
data.put("tip2","距离500M 1680人光顾");
data.put("img","http://example.com/test/fs/3.jpg");
bannerData.add(data);

//绑定数据
customBanner.setData(bannerData, R.layout.item_banner, new CustomBanner.BindView<Map<String,String>>() {
    @Override
    public void bind(Map<String, String> data, View rootView, int index) {
        SimpleDraweeView imgBkg = rootView.findViewById(R.id.img_bkg);
        TextView txtTitle = rootView.findViewById(R.id.txt_title);
        TextView txtAddress = rootView.findViewById(R.id.txt_address);
        TextView txtInfo = rootView.findViewById(R.id.txt_info);
        imgBkg.setImageURI(data.get("img")+"");
        txtTitle.setText(data.get("title")+"");
        txtAddress.setText(data.get("tip")+"");
        txtInfo.setText(data.get("tip2")+"");
    }
});

此时可以看到,CustomBanner 提供的接口 BindView 可以传入一个泛型,它决定了您的数据类型,可以如上述代码是一个 Map,也可以是您自定义的 JavaBean。

接口实现的方法中将子界面的数据(data)和子界面的根布局(rootView)返回,您可以使用 rootView.findViewById(resId) 来获取您的组件的实例化对象,并对其进行设值、绑定事件等操作。

开源协议

Copyright FastBanner

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

更新日志

v1.0.4:

  • 内存泄漏问题修复;

v1.0.3:

  • 新增 indicatorVisibility 属性控制指示器是否显示;

v1.0.2:

  • 新增回调参数 index,该值为数据下标;

v1.0.1:

  • 全新发布;
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].