github 地址https://github.com/1104436107/Banner_master_milaoshu
1主要有两种模式 convenientBanner.OpenBanner(false); 普通模式 convenientBanner.OpenBanner(true); banner模式
/** * @param model true 打开banner模式 false 普通模式 默认打开 */ public void OpenBanner(boolean model) { if (model == false) { RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams (LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); lp.setMargins(0, 0, 0, 0); viewPager.setLayoutParams(lp); } }2 主MainActivity Activity 中 主要调用代码
/** * @param mcontext 上下文 * @param imagess 图片数组 * @param convenientBanner 控件 * @param title banner 样式 * @param mOnItemClickListener item的点击事件 */ new TakeTurns(this, null, convenientBanner,"RotateDown", new OnItemClickListener() { @Override public void onItemClick(int position){ } }); @Override public void onResume() { super.onResume(); //开始自动翻页 convenientBanner.startTurning(1000); } @Override public void onPause() { super.onPause(); //停止翻页 convenientBanner.stopTurning(); }3 标红的间距
<com.milaoshu.convenientbanner.view.CBLoopViewPager android:id="@+id/cbLoopViewPager" android:layout_width="match_parent" android:clipChildren="false" android:layout_marginRight="60dp" android:layout_marginLeft="60dp" android:layout_height="match_parent" /> android:layout_marginRight="60dp" android:layout_marginLeft="60dp" 设置margin就可以。。。 convenientBanner.getViewPager().setPageMargin(30); 设置图中白色部分的距离4 依赖库依赖就行,,,
github 地址https://github.com/1104436107/Banner_master_milaoshu 欢迎下载代码查看