Flexible banner base on RecyclerView
fir.im rxbanner_demo.apk
github rxbanner_demo.apk
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
} implementation 'com.github.leveychen:RxBanner:1.0.4'see Attributes
<cn.levey.bannerlib.RxBanner
android:id="@+id/rx_banner"
android:layout_width="match_parent"
android:layout_height="160dp"/> banner = findViewById(R.id.rx_banner);
banner
.setLoader(new ImageLoader()) // see `image loader`
.setConfig(config) // see `config`
.setDatas(iamgesUrls, titles)
.start();Fresco Glide Picasso UniversalImageLoader
custom your config, the priority is higher than the xml
RxBannerConfig config = banner.getConfig();
config.set(value);
...
banner.setConfig(config);
banner.start();you MUST set config before setDatas() and start()
banner.setOnBannerClickListener(new RxBannerClickListener())
onItemClick(int position, Object data)
onItemLongClick(int position, Object data)
banner.setOnBannerTitleClickListener(new RxBannerTitleClickListener())
onTitleClick(int position, String title)
banner.setOnBannerChangeListener(new RxBannerChangeListener())
onBannerSelected(int position)
onBannerScrollStateChanged(int state)
onGuideFinished() banner.setCustomIndicator(indicator)
banner.setOnBannerChangeListener(new RxBannerChangeListener() {
@Override
public void onBannerSelected(int position) {
indicator.setSelection(position)
}
@Override
public void onBannerScrollStateChanged(int state) {
}
})lifecycle for Activity or Fragment and other views
banner.onResume()
banner.onPause()
banner.onDestroy() RxBannerConfig
.getInstance()
.setDebug(true) // debug: default false
.setScrollStateChangedListener(new RxBannerScrollStateChangedListener()
.setLoader(new RxBannerImageViewLoader())
.setOrientation(LinearLayout.HORIZONTAL)
.setOrderType(RxBannerConfig.OrderType.ASC)
.setTimeInterval(5000);just custom layout
then
banner.setOnBannerChangeListener(new RxBannerChangeListener())
onGuideFinished()
// todoall done
All the rb_ attributes here are specific for RxBanner
| Attributes | format | default | description |
|---|---|---|---|
| rb_autoPlay | boolean | true | auto play with rb_timeInterval delay |
| rb_infinite | boolean | true | infinite loop, if false will call onGuideFinished |
| rb_canSwipe | boolean | true | can swipe manually or not |
| rb_aspectRatio | float | / | should be greater than 0, android:layout_height NOT be wrap_content or match_parent. recommend 1dp |
| rb_timeInterval | integer (millisecond) |
5000 | for better performance, rb_timeInterval should be greater than 200 millisecond |
| rb_orientation | horizontal / vertical | horizontal | layout orientation |
| rb_itemPercent | integer | 100 | item width or height percentage |
| rb_itemScale | float | 1 | banner item scale |
| rb_itemSpace | dimension | 0 | banner item space |
| rb_centerAlpha | float | 1 | center item alpha |
| rb_sideAlpha | float | 1 | side item alpha |
| rb_itemMoveSpeed | float | 1 | fling speed |
| rb_orderType | asc / desc | asc | / |
| rb_viewPaperMode | boolean | true | one fling one paper like ViewPaper |
| rb_emptyViewText | string | 'No Banner' | display when data is empty and 'rb_emptyViewResource' not define |
| rb_emptyViewResource | reference | / | display when data is empty |
| Attributes | format | default | description |
|---|---|---|---|
| rb_title_visible | boolean | true | view visibility |
| rb_title_gravity | gravity | START | text gravity |
| rb_title_layout_gravity | gravity | CENTER_HORIZONTAL and BOTTOM | layout gravity |
| rb_title_margin | dimension | 0dp | margin |
| rb_title_padding | dimension | 3dp | padding |
| rb_title_width | dimension / enum | MATCH_PARENT | / |
| rb_title_height | dimension / enum | WRAP_CONTENT | / |
| rb_title_size | dimension | 14sp | / |
| rb_title_color | color | Color.WHITE | / |
| rb_title_backgroundColor | color | #55000000 | / |
| rb_title_backgroundResource | reference | / | / |
| rb_title_marquee | boolean | true | / |
| rb_title_lineSpacingMultiplier | float | 1.0f | lineSpacingMultiplier |
| Attributes | format | default | description |
|---|---|---|---|
| rb_indicator_visible | boolean | true | view visibility |
| rb_indicator_clickable | boolean | true | clicke position to change banner selection |
| rb_indicator_orientation | horizontal / vertical | horizontal | layout orientation |
| rb_indicator_layout_gravity | gravity | BOTTOM / END | layout gravity |
| rb_indicator_radius | dimension | 5dp | indicator radius |
| rb_indicator_textSize | dimension | 14sp | numeric numeric_circle only |
| rb_indicator_textColor | color | Color.WHITE | numeric numeric_circle only |
| rb_indicator_backgroundColor | color | / | numeric numeric_circle only |
| rb_indicator_backgroundResource | reference | / | numeric numeric_circle only |
| rb_indicator_scale | float | 0.7 | scale or scale_down only |
| rb_indicator_margin | dimension | 8dp | margin |
| rb_indicator_padding | dimension | 3dp | padding |
| rb_indicator_selected_color | color | #FFFFFF | / |
| rb_indicator_unselected_color | color | #33FFFFFF | / |
| rb_indicator_interactiveAnimation | boolean | false | / |
| rb_indicator_animationDuration | integer | 350 | millisecond |
| rb_indicator_animationType | type | none | see AnimationType |
| rb_indicator_rtl_mode | on / off / auto | auto | support RTL |
forked from PageIndicatorView
display images from network
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> -keep class cn.levey.bannerlib.** {
*;
}See release notes on Github Releases
ViewPagerLayoutManager and PageIndicatorView
Apache-2.0. See LICENSE for detail












