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?

  • Strange “nameValuePairs” key appear when using Gson
  • Using ViewPagerIndicator library with Android Studio and Gradle
  • Sniffing/logging your own Android Bluetooth traffic
  • Intent for selecting wallpaper with wallpaper region highlighting
  • How to Open Calendar App on a specific calendar
  • Android - How to programmatically set the button style in a Linearlayout?
  • Related posts:

    How to scale bitmap to screen size?
    registerContentObserver() on raw SQLite Cursor
    How to change styling of TextInput placeholder in React Native?
    Why is this not working sometimes?
    IntelliJ Idea giving java.lang.OutOfMemoryError: Java heap space error even after increasing heap si...
    View.onMeasure() not called
  • Android move object along a path
  • What is the point of encrypting anyting in Android (or Java) if source code can be reverse engineered?
  • How to get obj key from FirebaseListAdapter on Item Click. FirebaseUI
  • Get the distance between two geo points
  • how to access the drawable resources by name in android
  • Cancel an AlarmManager pendingIntent in another pendingintent
  • One Solution collect form web for “ViewStub vs. View.GONE”

    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.

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.