saiwu-bigkoo / Android-ConvenientBanner

Simple and convenient banner, loop viewpager with 3D effects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ItemView宽度为0的问题

androidWht opened this issue · comments

我直接new一个ConvenientBanner,然后addview到布局中也是会这样,item的宽度都是0,但是高度有值。如果直接在xml中写的话就不会。

 convenientBanner.setPages(new CBViewHolderCreator()
        {
            @Override
            public ImageHolderView createHolder(View itemView)
            {
                ViewGroup.LayoutParams layoutParams = itemView.getLayoutParams();
                layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
                return new ImageHolderView(itemView);
            }

            @Override
            public int getLayoutId()
            {
                return R.layout.item_banner;
            }
        }, strings);

这样我试了是可以的 宽度正常了