Are “GONE” views detrimental to performance?

前端 未结 2 1244
再見小時候
再見小時候 2021-02-03 18:07

I\'m making an app in which it might save me some time to have a single layout for several activities, with some of the views set to GONE depending on which activity is being us

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-03 19:04

    Here is an interesting answer. I was wondering the same thing as you, and the answer is that View.GONE consumes more memory than simply calling removeView(view) on the view. However, GONE views do consume less memory than View.VISIBLE since they do not need to be drawn.

    The memory amounts compare like this:

    View.VISIBLE > View.GONE > removing the view from the container

    What I do is use View.GONE on views that don't consume a lot of memory (like a TextView) and use parent.removeView(view) on views that are a lot of memory (like a WebView);

提交回复
热议问题