当前位置:网站首页>ViewPager2实现画廊效果执行notifyDataSetChanged后PageTransformer显示异常 界面变形问题
ViewPager2实现画廊效果执行notifyDataSetChanged后PageTransformer显示异常 界面变形问题
2022-04-23 06:08:00 【张海龙_China】

项目中要用到画廊滑动效果,选择了用ViewPager2的CompositePageTransformer去实现,
val compositePageTransformer = CompositePageTransformer()
compositePageTransformer.addTransformer(MarginPageTransformer(dip2px(20f)))
compositePageTransformer.addTransformer { view, position ->
logger.d("addTransformer() position : " + position)
val r = 1 - Math.abs(position)
view.scaleY = 0.90f + r * 0.1f
}
写完后效果预览没有问题,但是测试发现当频繁调用notifyDataSetChanged后,画廊效果就变形了,当左右滑动下效果又恢复了
解决办法:当ViewPager2的Adapter调用notifyDataSetChanged或者notifyItemChanged的时候ViewPager2调用下:
setCurrentItem
就是:
mViewPager.currentItem = mCurrentPosition
版权声明
本文为[张海龙_China]所创,转载请带上原文链接,感谢
https://blog.csdn.net/Jason_HD/article/details/121808007
边栏推荐
- [exynos4412] [itop4412] [android-k] add product options
- pg库对姓名进行校验
- iTOP4412内核反复重启
- org.xml.sax.SAXParseException; lineNumber: 141; columnNumber: 252; cvc-complex-type.2.4.a: 发现了以元素 ‘b
- Oracle索引状态查询与索引重建
- 补补网络缺口
- Itop4412 kernel restarts repeatedly
- Dolphinscheduler配置Datax踩坑记录
- RAC环境alert日志报错Drop transient type: SYSTP2JW0acnAurDgU1sBqMBryw==的排查
- Typical application scenarios of alicloud log service SLS
猜你喜欢

谷歌AdMob广告学习

oracle undo使用率高问题处理

oracle通过触发器和序列来定义自增主键,并且设置定时任务每秒钟插入一条数据到目标表

开篇:双指针仪表盘的识别

Cause: dx.jar is missing

Static interface method calls are not supported at language level ‘5‘ 异常解决

Explore how @ modelandview can forward data and pages through the source code

实习做了啥

iTOP4412 HDMI显示(4.4.4_r1)

JVM basics you should know
随机推荐
接口幂等性问题
oracle用delete删除数据所需时间测试
Try catch cannot catch asynchronous errors
Antd Design Form表单检验
mysql和pgsql时间相关操作
[Exynos4412][iTOP4412][Android-K]添加产品选项
Itop4412 kernel restarts repeatedly
Comparison between Prometheus thanos and cortex components
谷歌AdMob广告学习
通过rownum来进行区间查询
Ali vector library Icon tutorial (online, download)
Prometheus cortex Architecture Overview (horizontally scalable, highly available, multi tenant, long-term storage)
Thanos compact component test summary (processing historical data)
Android面试计网面经大全【持续更新中。。。】
Oracle redo log产生量大的查找思路与案例
pg库对姓名进行校验
Apache Atlas 编译及安装记录
Component learning
iTOP4412 SurfaceFlinger(4.4.4_r1)
Oracle RAC数据库实例启动异常问题分析IPC Send timeout