Suppose you have a FrameLayout
containing 10 LinearLayouts
, where only one is visible per time.
Each LinearLayout
is a complex view, containing Button
, EditText
, TextView
, etc.
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/alice
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible">
<!-- complex stuff -->
</LinearLayout>
<!-- many more linear layouts... -->
<LinearLayout
android:id="@+id/juliett
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
<!-- last complex stuff -->
</LinearLayout>
</FrameLayout>
Thus:
LinearLayout
visibility, in order to show another item, would be a huge performance issue?ViewFlipper
does not slow down the app performance?It's bad practice because the code easily become a mess. Ignoring that and focusing only on performance, when you set the visibility to GONE
, the view isn't measured (it's different from INVISIBLE
). The view occupies a little bit of memory, though. Depending on what you're doing, consider using ViewGroup.removeView()
.
It's hard to say without a benchmark, but theoretically it shouldn't have performance issues.