Estoy teniendo problemas reales tratando de alinear fragmentos con un RelativeLayout
, aunque parece que esto debería ser sencillo. Sólo necesito dos fragmentos lado de la otra y si uso un LinearLayout
funciona bien:Alineando fragmentos con RelativeLayout
<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>
Sin embargo, si uso un RelativeLayout
, no aparece nada:
<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>
Actualización:
Aquí está una captura de pantalla de lo que estoy viendo:
Este es el código que estoy usando:
<?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>
Lo que al final estoy tratando de hacer es agregar un pie de página en la parte inferior del diseño, pero no pude hacerlo funcionar con un 'LinearLayout'. Pude mostrar el pie de página usando un 'RelativeLayout', pero luego los fragmentos no aparecían, así que solo intentaba hacer aparecer los fragmentos (sin el pie de página), de ahí mi pregunta. Parece que voy a tener que descubrir cómo hacer que el pie de página funcione con un "LinearLayout". Básicamente, quiero un diseño donde el fragmento de la izquierda ocupa 1/3 de la pantalla, el derecho del resto de la pantalla, con un pie de página adhesivo. –
Correcto, eso no debería ser demasiado difícil de realizar. Por favor, mira la edición en mi respuesta y pruébalo. No lo he probado, pero debería estar (cerca de) lo que está buscando. –
Eso funcionó muy bien. ¡Gracias! –