Friday, November 9, 2012

[android-developers] RelativeLayout containing ViewStub doesn't position the inflated stub correctly

I've got a RelativeLayout declared via XML that contains a regular View and a ViewStub.  The regular View specifies android:layout_above="@+id/the_view_stub".  In my Fragment's onCreateView(), I'm first inflating the RelativeView, then conditionally inflating the stub.  However, the result is that the view that replaces the stub upon its inflation is overlaying the "regular" view, instead of being positioned below it.

When I substitute the stub's "target" layout directly into the RelativeLayout in the XML file (i.e. no stub, no conditional inflation), it works as expected.

At first, I thought maybe the problem was that the inflated view that replaced the ViewStub had a different ID than the stub, such that upon the 2nd layout, the first view in the RelativeLayout was still referencing the ID of the stub (which would no longer exist); however, making the IDs of the stub and its target the same, via android:inflatedId, didn't make any difference.

Then, I thought maybe I needed to call requestLayout() on the RelativeLayout after stub inflation, but that didn't make a difference, either.

Ideas?

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate