### Manage MZBannerView Lifecycle in Activity Source: https://github.com/pinguo-zhouwei/mzbannerview/blob/master/readme.md This snippet illustrates how to manage the MZBannerView's lifecycle by calling `pause()` in `onPause()` and `start()` in `onResume()`. This is crucial for proper banner behavior, especially when used as a looping banner, ensuring it pauses when the activity is not active and resumes when it becomes active. ```Java @Override public void onPause() { super.onPause(); mMZBanner.pause();//暂停轮播 } @Override public void onResume() { super.onResume(); mMZBanner.start();//开始轮播 } ``` -------------------------------- ### Configure MZBannerView for iQiyi Style Banner with Page Spacing Source: https://github.com/pinguo-zhouwei/mzbannerview/blob/master/readme.md This configuration demonstrates how to create an iQiyi-style banner with visible spacing between pages. It involves setting `open_mz_mode` to `true` and `middle_page_cover` to `false` in the `MZBannerView` layout, and crucially, adding `layout_marginLeft` and `layout_marginRight` to the `ImageView` within the banner item's layout. ```XML ``` ```XML ``` -------------------------------- ### Configure Maven Repository for MZBannerView Source: https://github.com/pinguo-zhouwei/mzbannerview/blob/master/readme.md This snippet shows how to add the JitPack Maven repository to your project's root `build.gradle` file, which is necessary to resolve the MZBannerView dependency. ```Java allprojects { repositories { ... maven { url 'https://jitpack.io' } } } ``` -------------------------------- ### Initialize MZBannerView and Set Data in Activity Source: https://github.com/pinguo-zhouwei/mzbannerview/blob/master/readme.md This Java code shows how to initialize the MZBannerView in an Android Activity and set its pages with data. It includes the implementation of a `BannerViewHolder` which defines how each banner item's view is created and how data is bound to it, typically an ImageView. ```Java mMZBanner = (MZBannerView) view.findViewById(R.id.banner); // 设置数据 mMZBanner.setPages(list, new MZHolderCreator() { @Override public BannerViewHolder createViewHolder() { return new BannerViewHolder(); } }); public static class BannerViewHolder implements MZViewHolder { private ImageView mImageView; @Override public View createView(Context context) { // 返回页面布局 View view = LayoutInflater.from(context).inflate(R.layout.banner_item,null); mImageView = (ImageView) view.findViewById(R.id.banner_image); return view; } @Override public void onBind(Context context, int position, Integer data) { // 数据绑定 mImageView.setImageResource(data); } } ``` -------------------------------- ### Configure MZBannerView as Standard ViewPager (Non-Looping) Source: https://github.com/pinguo-zhouwei/mzbannerview/blob/master/readme.md This XML configuration sets up MZBannerView to function as a regular, non-looping ViewPager. Both `canLoop` and `open_mz_mode` are set to `false`, resulting in a straightforward, non-overlapping page display. ```XML app:canLoop="false" app:open_mz_mode="false" ``` -------------------------------- ### MZBannerView Public API Methods Source: https://github.com/pinguo-zhouwei/mzbannerview/blob/master/readme.md Documents the public API methods available for controlling and configuring the MZBannerView component, including playback control, listener registration, and visual settings. These methods allow developers to interact with the banner's core functionalities. ```APIDOC MZBannerView Public API: start(): Starts the banner carousel. pause(): Stops the banner carousel. setDelayedTime(int delayedTime): Sets the time interval for banner switching. addPageChangeLisnter(ViewPager.OnPageChangeListener onPageChangeListener): Sets a page change listener. setBannerPageClickListener(BannerPageClickListener bannerPageClickListener): Adds a page click event listener. setIndicatorVisible(boolean visible): Sets whether the indicator is visible. getViewPager(): Returns the internal ViewPager instance. setIndicatorRes(int unSelectRes, int selectRes): Sets indicator resources for unselected and selected states. setPages(List datas, MZHolderCreator mzHolderCreator): Sets the page data. setIndicatorAlign(IndicatorAlign indicatorAlign): Sets the indicator display position. setDuration(int duration): Sets the ViewPager (Banner) switching speed. ``` -------------------------------- ### Configure MZBannerView for Standard Looping Banner Source: https://github.com/pinguo-zhouwei/mzbannerview/blob/master/readme.md This XML configuration demonstrates how to set up the MZBannerView as a standard looping banner. By setting `open_mz_mode` to `false` and `canLoop` to `true`, it provides a continuous, non-overlapping banner display. ```XML app:open_mz_mode="false" app:canLoop="true" ``` -------------------------------- ### Configure MZBannerView as Meizu Style ViewPager (Non-Looping) Source: https://github.com/pinguo-zhouwei/mzbannerview/blob/master/readme.md This XML configuration uses MZBannerView as a standard ViewPager with a Meizu-style visual effect. By setting `open_mz_mode` to `true` and `canLoop` to `false`, it provides the overlapping page appearance without continuous looping. ```XML app:open_mz_mode="true" app:canLoop="false" ``` -------------------------------- ### Integrate MZBannerView in XML Layout Source: https://github.com/pinguo-zhouwei/mzbannerview/blob/master/readme.md This XML snippet demonstrates how to declare the MZBannerView in an Android layout file. It includes attributes for width, height, margins, and custom properties like `open_mz_mode`, `canLoop`, `indicatorAlign`, and `indicatorPaddingLeft` to configure the banner's appearance and behavior. ```XML ``` -------------------------------- ### Set MZBannerView Indicator Properties Programmatically Source: https://github.com/pinguo-zhouwei/mzbannerview/blob/master/readme.md This Java code snippet illustrates how to programmatically set the alignment and padding for the MZBannerView's indicator. These configurations should be applied before calling `setPages()` for them to take effect. ```Java mMZBanner.setIndicatorAlign(MZBannerView.IndicatorAlign.LEFT); mMZBanner.setIndicatorPadding(10,0,0,150); ``` -------------------------------- ### Add MZBannerView Library Dependency Source: https://github.com/pinguo-zhouwei/mzbannerview/blob/master/readme.md This snippet demonstrates how to include the MZBannerView library as a compile dependency in your app's `build.gradle` file, specifying the version `v2.0.2`. ```Java dependencies { compile 'com.github.pinguo-zhouwei:MZBannerView:v2.0.2' } ``` -------------------------------- ### Configure MZBannerView for Meizu Style Banner (Middle Page Cover) Source: https://github.com/pinguo-zhouwei/mzbannerview/blob/master/readme.md This XML configuration sets the MZBannerView to mimic the Meizu-style banner effect where the middle page covers the adjacent pages. It enables `open_mz_mode`, `canLoop` for continuous looping, and `middle_page_cover` for the overlapping visual. ```XML app:open_mz_mode="true" app:canLoop="true" app:middle_page_cover="true" ``` -------------------------------- ### Set MZBannerView Indicator Properties in XML Layout Source: https://github.com/pinguo-zhouwei/mzbannerview/blob/master/readme.md This XML snippet demonstrates how to configure the MZBannerView's indicator alignment and padding directly within your layout file using custom attributes. These attributes allow for declarative styling of the banner's pagination indicator. ```XML app:indicatorAlign="center" app:indicatorPaddingLeft="10dp" app:indicatorPaddingBottom="50dp" app:indicatorPaddingRight="10dp" app:indicatorPaddingTop="50dp" ``` -------------------------------- ### MZBannerView Custom XML Attributes Reference Source: https://github.com/pinguo-zhouwei/mzbannerview/blob/master/readme.md This section provides a reference for the custom XML attributes available for `MZBannerView`. These attributes allow developers to configure the banner's behavior and appearance directly in layout files, controlling features like Meizu mode, auto-looping, indicator positioning, and middle page cover effects. ```APIDOC open_mz_mode: Description: Whether to enable Meizu mode. Values: true (Meizu Banner effect), false (normal Banner effect) canLoop: Description: Whether to enable auto-looping. Values: true (loop), false (normal ViewPager) indicatorPaddingLeft: Description: Sets the left padding of the indicator. Values: dp value indicatorPaddingRight: Description: Sets the right padding of the indicator. Values: dp value indicatorAlign: Description: Sets the position of the indicator. Values: left, center, right middle_page_cover: Description: Sets whether the middle page covers the sides (true Meizu Banner effect). Values: true (cover), false (no cover effect) ``` -------------------------------- ### Configure MZBannerView for Meizu Style Banner (No Middle Page Cover) Source: https://github.com/pinguo-zhouwei/mzbannerview/blob/master/readme.md This XML configuration achieves a Meizu-style banner effect where the middle page does not cover the adjacent pages. It enables `open_mz_mode` and `canLoop`, but explicitly sets `middle_page_cover` to `false` to prevent overlapping. ```XML app:open_mz_mode="true" app:canLoop="true" app:middle_page_cover="false" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.