当前位置:网站首页>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
边栏推荐
猜你喜欢
窗口分析函数LAST_VALUE,FIRST_VALUE,lag,lead
iTOP4412 HDMI显示(4.4.4_r1)
qs. In the stringify interface, the input parameter is converted into a & connected string (with the application / x-www-form-urlencoded request header)
组件化学习(3)ARouter中的Path和Group注解
Static interface method calls are not supported at language level ‘5‘ 异常解决
Ali vector library Icon tutorial (online, download)
Encapsulate a set of project network request framework from 0
ACFS文件系统创建扩大缩小等配置步骤
Chaos帶你快速上手混沌工程
项目,怎么打包
随机推荐
三种实现ImageView以自身中心为原点旋转的方法
补补网络缺口
When switch case, concatenate the error case and if of the conventional judgment expression and use L
iTOP4412内核反复重启
Itop4412 surfaceflinger (4.4.4_r1)
发布自定义插件到本地服务器
sys.dbms_scheduler.create_job创建定时任务(功能更强大丰富)
19C中ASM network未自动启动的处理
Try catch cannot catch asynchronous errors
测试oracle库700万数据量普通方式创建索引所需时间
Abnormal record-12
Implementation of multi tenant read and write in Prometheus cortex
Static interface method calls are not supported at language level ‘5‘ 异常解决
Exception record-6
解决:You have 18 unapplied migration(s). Your project may not work properly until you apply
How does VirtualBox modify the IP network segment assigned to the virtual machine in the "network address translation (NAT)" network mode
mysql和pgsql时间相关操作
Oracle RAC数据库实例启动异常问题分析IPC Send timeout
Typical application scenarios of alicloud log service SLS
Prometheus monitoring method and index interpretation of influxdb