> After updating from > com.android.support:support-v13:21.0.0 > > to > com.android.support:support-v13:22.0.0 > > I noticed a very important change in behaviour of the > getView() > > method of > android.support.v4.app.Fragment > > With version 21, getView() returns a > NoSaveStateFrameLayout > > which then contains as a single child the Layout that was inflated in the > Fragments onCreateView method. > > With version 22, getView() returns the inflated layout itself, without the > enclosing NoSaveStateFrameLayout. > > This is, for me, reproducable on the most simple app (Android Studio > wizard, Activity with Fragment) and reproducable all the time. > This can cause trouble if you use the getView() method to retrieve the > fragment's view at runtime and rely, for example, on the first child of > getView() being a ViewGroup of a certain type (LinearLayout, ...). >
The javadoc is the problem. It says it *always* returns the view from onCreateView and it never did and still doesn't... > Perhaps someone can explain > > a. what the NoSaveStateFrameLayout is, > A "wrapper" FrameLayout that does not save its child state, when a "state saving traversal occurs from its parent" (eg. when the activity saves the view hiearchy). It is basiaclly a workaround for View#setSaveFromParentEnabled() <https://developer.android.com/reference/android/view/View.html#setSaveFromParentEnabled%28boolean%29>, which was only added in Honeycomb. > b. why it isn't used anymore and > It still is <https://android.googlesource.com/platform/frameworks/support/+/5e63ab9505a3a4d11374cbbec418c1aba921409d%5E!/>, but not on Honeycomb or later because there is no need to. I actually prefer this behaviour, less clutter on the hierarchy viewer and its the same behaviour as the framework implementation. > c. if the behaviour of com.android.support:support-v13:22.0.0 is intended > that way. > > Best regards, Florian > -- You received this message because you are subscribed to the Google Groups "adt-dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
