Android Invalidate() only single view

眉间皱痕 提交于 2019-12-20 02:55:01

问题


I have 2 views on RelativeLayout

I need to invoke(call) onDraw only single view

when I try view1.invalidate(); it also invoke(call) onDraw (view2 draw)

what to do?

thanks


回答1:


if view1 is overlapping with view2 when you call view1.invalidate(); it will re-draw every View that is overlapping with it .. so it will call view2.onDraw(); and since you are using RelativeLayout view1 and view2 maybe overlapped each other .




回答2:


I met the same question.

Finally, I found that drawing cache is disabled in android 2.3. Because of no cache, each time the view will redraw itself even the other invalidated.

To make cache enable, use:

setDrawingCacheEnabled(true)

The question is too old, but google put it first when I searched. I think it is useful for others who get into here.



来源:https://stackoverflow.com/questions/8120986/android-invalidate-only-single-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!