I faced strange ViewStub behavior in RelativeLayout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ViewStub
android:id="@+id/stub"
android:inflatedId="@+id/stub"
android:layout="@layout/some_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"/>
<TextView
android:id="@+id/text1"
android:layout_width="match_parent"
android:text="Some text"
android:layout_height="wrap_content"/>
<TextView
android:layout_above="@id/stub"
android:layout_width="match_parent"
android:text="Some text2"
android:layout_height="wrap_content"/>
</RelativeLayout>
When inflating layout above it looks like viewstub is aligned to parent top but not bottom. I also have tried to set ViewStub height and width in fixed values (dp or px) but got same result. So is it some kind of Android bug or i missed something with ViewStub?
For example if i'll replace ViewStub with simple View and same RelativeLayout proprties all views infleted in proper way:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:id="@+id/stub"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_alignParentBottom="true"/>
<TextView
android:id="@+id/text1"
android:layout_width="match_parent"
android:text="Some text"
android:layout_height="wrap_content"/>
<TextView
android:layout_above="@id/stub"
android:layout_width="match_parent"
android:text="Some text2"
android:layout_height="wrap_content"/>
</RelativeLayout>
Edit: I'm not calling inflate on ViewStub. In case inflate method called on ViewStub all works perfect.