简体   繁体   English

Android:仅更改布局时避免视图无效

[英]Android: Avoid view invalidate when only layout is changed

When animating height of an item in ListView , the setViewValue() method in the ViewBinder is called several times for each layout change, making the animation very slow. ListView项目的高度动画时,每次更改布局都会多次调用ViewBindersetViewValue()方法,这会使动画非常慢。

I am currently solving it by setting a disableViewUpdate flag in onAnimationStart() and turning it off in onAnimationEnd() . 我目前通过设置解决它disableViewUpdateonAnimationStart()并在将其关闭onAnimationEnd() setViewValue() returns true if the flag is set, avoiding any database lookup. 如果设置了该标志,则setViewValue()返回true ,从而避免任何数据库查找。 But there are still tens or hundreds of calls to setViewValue() during each animation step. 但是在每个动画步骤中仍然有数十或数百个setViewValue()调用。

My question is: Is there a way to avoid setViewValue() being called as a result of layout changes? 我的问题是:有没有一种方法可以避免由于布局更改而调用setViewValue()

I would just go for inheriting from ListView, overriding the method and then avoiding any action when the method is called and the view is animating. 我只想从ListView继承,重写该方法,然后在调用该方法且视图处于动画状态时避免任何操作。

Hope this helps :) 希望这可以帮助 :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM