当前位置:网站首页>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
边栏推荐
猜你喜欢
双指针仪表盘读数(一)
组件化学习(3)ARouter中的Path和Group注解
从0开始封装一套项目的网络请求框架
Binder机制原理
实习做了啥
Dolphinscheduler集成Flink任务踩坑记录
Try catch cannot catch asynchronous errors
记录webView显示空白的又一坑
qs. In the stringify interface, the input parameter is converted into a & connected string (with the application / x-www-form-urlencoded request header)
专用窗口函数rank, dense_rank, row_number
随机推荐
oracle给对象重命名
qs. In the stringify interface, the input parameter is converted into a & connected string (with the application / x-www-form-urlencoded request header)
Oracle索引状态查询与索引重建
iTOP4412无法显示开机动画(4.0.3_r1)
iTOP4412 HDMI显示(4.0.3_r1)
oracle库恢复数据
【机器学习】笔记 4、KNN+交叉验证
测试oracle库700万数据量普通方式创建索引所需时间
ORACLE环境遇到的ORA-600 [qkacon:FJswrwo]
10g数据库使用大内存主机时不能启动的问题
RAC环境alert日志报错Drop transient type: SYSTP2JW0acnAurDgU1sBqMBryw==的排查
Information:2021/9/29 10:01 - Build completed with 1 error and 0 warnings in 11s 30ms Error异常处理
SQL中 with函数的详解与用法
Comparison between Prometheus thanos and cortex components
error 403 In most cases, you or one of your dependencies are requesting解决
Exception record-9
Itop4412 kernel restarts repeatedly
利用栈实现队列的出队入队
oracle表的约束详解
个人博客网站搭建