xbanner實現卡片式輪播

思敏吖發表於2020-09-26

在這裡插入圖片描述

 implementation 'com.github.xiaohaibin:XBanner:1.6.1'
  <com.stx.xhb.xbanner.XBanner
                    android:id="@+id/xbanner"
                    android:layout_width="wrap_content"
                    android:layout_height="350dp"
                    android:layout_centerHorizontal="true"
                    android:layout_centerVertical="true"
                    app:AutoPlayTime="100000"
                    app:clipChildrenLeftRightMargin="40dp"
                    app:isClipChildrenMode="true"
                    app:pointsContainerBackground="#00000000"
                    app:pointsPosition="CENTER"
                    app:pointsVisibility="true" />
 for (int i = 0; i < invitecodeBean.size(); i++) {
                        img_list.add(invitecodeBean.get(i).getImage());
                    }
                    xbanner.setData(img_list, null);
                    xbanner.setViewPagerMargin(20);//中間item距離兩邊的間距
                    xbanner.loadImage(new XBanner.XBannerAdapter() {


                        @Override
                        public void loadBanner(XBanner banner, Object model, View view, int position) {
                            RequestOptions myOptions = new RequestOptions()
                                    .transform(new GlideRoundTransform(getActivity(), 10));

                            Glide.with(getActivity())
                                    .load(img_list.get(position))
                                    .apply(myOptions)
                                    .into((ImageView) view);

                        }
                    });

相關文章