I'm having real issues aligning fragments with RelativeLayout
, although it seems like it should be simple. I just need two fragments next to each other, and if I use LinearLayout
, it works fine:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent"> <fragment android:name="com.fragment.test.TitlesFragment" android:id="@+id/fragmentTitles" android:layout_weight="1" android:layout_width="0dp" android:layout_height="fill_parent" /> <FrameLayout android:id="@+id/details" android:layout_weight="1" android:layout_width="0px" android:layout_height="fill_parent" /> </LinearLayout>

However, if I use RelativeLayout
, it shows nothing:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent"> <fragment android:name="com.fragment.test.TitlesFragment" android:id="@+id/fragmentTitles" android:layout_weight="1" android:layout_width="0dp" android:layout_height="fill_parent" /> <FrameLayout android:id="@+id/details" android:layout_weight="1" android:layout_width="0px" android:layout_height="fill_parent" android:layout_toRightOf="@id/fragmentTitles" /> </RelativeLayout>

Update:
Here is a screenshot of what I see:

This is the code I'm using:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <LinearLayout android:orientation="horizontal" android:layout_height="fill_parent" android:layout_width="fill_parent" android:weightSum="3" > <fragment android:name="com.fragment1" android:id="@+id/fragment1" android:layout_weight="1" android:layout_width="0dp" android:layout_height="fill_parent" android:layout_above="@id/statusUpdated" /> <fragment android:name="com.fragment2" android:id="@+id/fragment2" android:layout_width="0px" android:layout_weight="2" android:layout_height="fill_parent" android:layout_above="@id/statusUpdated" android:layout_toRightOf="@id/fragment1" /> </LinearLayout> <TextView android:id="@+id/statusUpdated" style="@style/Status" /> </RelativeLayout>
source share