Trace: requestLayout() improperly called?

后端 未结 2 1075
一整个雨季
一整个雨季 2021-01-03 21:24

Can anyone tell me how to fix the following trace:

W/View    (16810): requestLayout() improperly called by 
theme.effects.TopCenterImageView{41dc73f0 V.ED...         


        
相关标签:
2条回答
  • 2021-01-03 22:06

    I changed a child views layout params in the onLayout method AFTER calling super.onLayout(); That lead to a recursion:

    Childlayout params changed -> parent view onRequestLayout() -> parent view onLayout -> childview params changed -> ...

    0 讨论(0)
  • 2021-01-03 22:24

    As seen here, setScaleType will call requestLayout, but the constructor of ImageView already call it before. So it will cause the layout to have multiple requestLayout called, one during the layout pass. It's just a warning because at a small scale, it's not a problem.

    You will find some good research in this thread (not the roboguice part though).

    0 讨论(0)
提交回复
热议问题