BannerLayout
Support unlimited picture rotation BannerLayout, the minimum implementation of the code banner.
Support function
- can be customized dots , title, prompt bar position,Support for custom selectors
- you can customize small dots, and whether to automatically rotate to the next page and rotation time
- support for click events and rotation speed and viewPager slide switch speed
- whether to display a dots, title, or the entire tip column
- support for loading and loading fails to display custom pictures
- supports pause to resume the rotation status
- supports animation and vertical scrolling
Effect
Basic Usage
gradle
api 'com.ydevelop:bannerlayout:1.1.3'
maven
<dependency>
<groupId>com.ydevelop</groupId>
<artifactId>bannerlayout</artifactId>
<version>1.1.3</version>
<type>pom</type>
</dependency>
recommended to look at Sample : SimpleActivity
If the network is loading pictures remember to add
<uses-permission android:name="android.permission.INTERNET" />
simple to use
Bean class please implement BannerModelCallBack
Specific reference SimpleBannerModel
If you use the built-in frame, please rely on glide
implementation 'com.github.bumptech.glide:glide:4.8.0'
or
class ImageLoaderSimpleManager : ImageLoaderManager<SimpleBannerModel> {
override fun display(container: ViewGroup, model: SimpleBannerModel): ImageView {
val imageView = ImageView(container.context)
val imageLoader = ImageLoader.getInstance()
imageLoader.displayImage(model.bannerUrl, imageView)
return imageView
}
}
see :ImageManagerSimple
simple:
banner.resource(data).switchBanner(true/false);
Vertical scrolling
banner.setVertical(true)
PageChangeListener
bannerLayout.onBannerChangeListener = object : OnBannerChangeListener {
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
}
override fun onPageSelected(position: Int) {
}
override fun onPageScrollStateChanged(state: Int) {
}
}
Click the event
If you do not pass generics, the return model is the current Bean class, strong turn can be recommended to pass generics
bannerLayout.onBannerClickListener = object : OnBannerClickListener<SimpleBannerModel> {
override fun onBannerClick(view: View, position: Int, model: SimpleBannerModel) {
}
}
Tip column and small dots, title position changes
tipsSite The location of the tip bar in the layout,top,bottom,center Three optional
dotsSite dots in the location of the prompt bar,left,center,right Three optional
titleSite Title The location of the prompt bar,left,center,right Three optional
xml:
<com.bannerlayout.widget.BannerLayout
...
app:tips_site="center" />
Toggle animation and speed
Viewpager vertical Here is the use of animation, so long as the choice of vertical scrolling, setting animation invalid
Animation built-in ViewPagerTransforms,Thank the author
If you want to customize the animation, please inherit ABaseTransformer or BannerTransformer ;
banner.bannerTransformerType = BannerLayout.ANIMATION_CUBE_IN
or
banner.bannerTransformer = ZoomOutSlideTransformer()
Animation collection:
List<BannerTransformer> bannerTransformer = new ArrayList<>();
etBannerSystemTransformerList(bannerTransformer);
java method
see: MethodTestActivity
bannerLayout
.apply {
delayTime = 3000
errorImageView = R.mipmap.ic_launcher
placeImageView = R.mipmap.ic_launcher
bannerDuration = 3000
viewPagerTouchMode = true
isVertical = true
titleColor = ContextCompat.getColor(applicationContext, R.color.colorPrimaryDark)
titleSize = 23F
tipsLayoutBackgroundColor = ContextCompat.getColor(applicationContext, R.color.colorAccent)
dotsSelector = R.drawable.banner
tipsWidth = BannerLayout.MATCH_PARENT
tipsHeight = 300
tipsSite = BannerLayout.TOP
...
}
.initPageNumView()
.initTips()
.resource(SimpleData.initModel())
.switchBanner(true)
xml method
xml default parameter see:
app:banner_guide="true"
app:banner_dots_visible="true"
app:banner_page_num_radius="2"
app:banner_page_num_paddingLeft="10"
app:banner_page_num_paddingTop="10"
app:banner_page_num_paddingRight="10"
app:banner_page_num_paddingBottom="10"
app:banner_page_num_marginTop="10"
app:banner_page_num_marginLeft="10"
app:banner_page_num_marginRight="10"
app:banner_page_num_marginBottom="10"
app:banner_page_num_textColor="@color/colorYellow"
app:banner_page_num_textSize="22sp"
app:banner_page_num_BackgroundColor="@color/colorYellow"
app:banner_page_num_mark="@string/app_name"
app:banner_pageNum_site="bottomRight"
app:banner_tips_site="bottom"
app:banner_dots_site="center"
app:banner_title_site="center"
app:banner_start_rotation="true"
app:banner_title_visible="true"
app:banner_title_size="10sp"
app:banner_title_color="@color/colorYellow"
app:banner_title_width="200"
app:banner_title_height="60"
app:banner_title_left_margin="60"
app:banner_title_right_margin="60"
app:banner_dots_left_margin="40"
app:banner_dots_right_margin="40"
app:banner_dots_width="30"
app:banner_dots_height="30"
app:banner_enabledRadius="2"
app:banner_enabledColor="@color/colorAccent"
app:banner_normalRadius="2"
app:banner_normalColor="@color/colorBackground"
app:banner_glide_error_image="@mipmap/ic_launcher"
app:banner_glide_place_image="@mipmap/ic_launcher"
app:banner_is_tips_background="true"
app:banner_tips_background="@color/colorAccent"
app:banner_tips_width="match_parent"
app:banner_tips_height="300"
app:banner_dots_selector="@drawable/banner"
app:banner_start_rotation="true"
app:banner_delay_time="300"
app:banner_duration="3000"
app:banner_view_pager_touch_mode="true"