Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

控件缩小的问题 #308

Open
tsdl2018 opened this issue Apr 14, 2023 · 5 comments
Open

控件缩小的问题 #308

tsdl2018 opened this issue Apr 14, 2023 · 5 comments

Comments

@tsdl2018
Copy link

用了这个bannerview ,app一进来先正常显示然后又缩小,变成这个样子,你们遇到过吗?然后手动滑动又正常了,下次进来都正常。
代码如下:
parkCardBanner.setLifecycleRegistry(getLifecycle()).setAdapter(vehicleAdapter).setAutoPlay(false).setInterval(2000).setPageMargin(5).setRevealWidth(5).setIndicatorVisibility(View.GONE).setIndicatorView(indicatorViewHome)
// .setIndicatorSlideMode(IndicatorSlideMode.COLOR)
.setPageStyle(PageStyle.MULTI_PAGE_SCALE);

  parkCardBanner.create(vehicleInfoList);

40JB$~%CZDI7{0C (XSPT)P

@287138531
Copy link

同样遇到这个问题,出现是refreshData()之后setCurrentItem

@530l
Copy link

530l commented Jul 21, 2023

有解决吗

@287138531
Copy link

有解决吗

用 create(item.list) 去刷新数据,解决了

@530l
Copy link

530l commented Jul 21, 2023

这样不算解决

@Mingyueyixi
Copy link

有解决吗

用 create(item.list) 去刷新数据,解决了

这其实是recyclerview的瓜,viewpager2 如果应用了缩放也存在类似的问题,当你刷新的时候,list通常是这样的:

list.clear();
list.addAll(newDataList);
adapter.notifyDataSetChange();

咋一看没啥问题,的确,一般的界面recycleView是不会存在问题的。但当你原本的界面存在缩放item时,recyclerView会因为缓存,导致错乱。
所以解决方法是在清空旧的列表数据时,adapter也进行视图更新(list本来就应该每操作一次,notify一次)

list.clear();
notifyItemRangeRemoved(0, list.size);
list.addAll(newDataList);
// notifyItemRangeInserted(0, list.size)
adapter.notifyDataSetChange();

但这么做,也可能带来新的问题,就是刷新闪现,因为缓存无了,加上动画闪现。
所以,也可以尝试使用类似代码来规避:
notifyItemRangeChanged(0, list.size)

当然,还有直接替换adapter或嘎一个新的recyclerview应该也是可以的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants