Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ViewStub vs. View.GONE

As far as I undestand, neither a ViewStub nor a View that's GONE participate in the measure and layout passes (or rendering anyway).

Is there a difference in rendering performance? What's the best practice about when to use which?

like image 430
Matthias Avatar asked Aug 19 '10 11:08

Matthias


1 Answers

The rendering performance comes into picture when you are inflating the views.

My guess is that its much cheaper to inflate a ViewStub than to inflate a View, either from XML or by changing visibility. ViewStub is especially used when you need to add/remove (indefinite) views (eg. add phone numbers to a given contact). Hope this is what you were looking for.

like image 188
Sameer Segal Avatar answered Sep 24 '22 11:09

Sameer Segal