GalleryLayoutManager
GalleryLayoutManager copied to clipboard
使用GalleryLayoutManager之后item显示不出来
这是我的代码 List<String> lisr = new ArrayList<>(); for (int i = 0; i <20 ; i++) { lisr.add("item"+i); } adapter = new NoticeBannerAdapter(lisr); new GalleryLayoutManager(GalleryLayoutManager.HORIZONTAL).attach(recycleBanner); recycleBanner.setAdapter(adapter);
下面是打印出来的日志
D/GalleryLayoutManager: onLayoutChildren() called with: state = [State{mTargetPosition=-1, mData=null, mItemCount=20, mIsMeasuring=false, mPreviousLayoutItemCount=0, mDeletedInvisibleItemCountSincePreviousLayout=0, mStructureChanged=true, mInPreLayout=false, mRunSimpleAnimations=false, mRunPredictiveAnimations=false}] reset: D/GalleryLayoutManager: firstFillCover finish:first: 0,last:0 V/GalleryLayoutManager: onScrolled: dx:0,dy:0 onScrolled: dx:0,dy:0 D/GalleryLayoutManager: onLayoutChildren() called with: state = [State{mTargetPosition=-1, mData=null, mItemCount=20, mIsMeasuring=false, mPreviousLayoutItemCount=20, mDeletedInvisibleItemCountSincePreviousLayout=0, mStructureChanged=false, mInPreLayout=false, mRunSimpleAnimations=false, mRunPredictiveAnimations=false}] onLayoutChildren: ignore extra layout step D/OpenGLRenderer: endAllActiveAnimators on 0x7f7c70c000 (RippleDrawable) with handle 0x7f7decc840
请问下我是不是哪里写的有点问题,我把这些代码复制到一个新开的项目,能显示,然后在自己项目中引用就显示不出来,我看打印出来的日志mItemCount是有20条的。
我也遇到这个问题,请问解决了吗
@VliceZ 我记得这个问题好像是因为高度设置的warp-content导致的,给他设置一个高度就好了
@tx123456 根布局有设置固定高度,但还是显示不出item。 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:orientation="vertical" android:layout_width="210dp" android:layout_height="118dp" android:layout_marginLeft="12dp" android:layout_marginRight="12dp" >
@VliceZ 你的recycleView设置了高度没有
@tx123456 recycleView设置了固定高度解决了,非常感谢! @BCsl 希望能够说明一下避免更多人踩坑