Lo siento por el gran volcado de código, pero estoy realmente perdido.Android Fragment no respeta match_parent como altura
MyActivity.java onCreate:
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_singlepane_empty);
mFragment = new PlacesFragment();
getSupportFragmentManager().beginTransaction()
.add(R.id.root_container, mFragment)
.commit();
PlacesFragment.java onCreateView:
mRootView = (ViewGroup) inflater.inflate(R.layout.list_content, null);
return mRootView;
Notas: mRootView es un ViewGroup mundial, no hay problema en ello, creo. PlacesFragment es un ListFragment.
diseños:
activity_singlepane_empty.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/root_container"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00f">
<include layout="@layout/actionbar"/>
<!-- FRAGMENTS COME HERE! See match_parent above -->
</LinearLayout>
list_content.xml:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/listContainer"
android:background="#990"
>
<ListView android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:drawSelectorOnTop="false" />
<TextView android:id="@id/android:empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/no_data_suggest_connection"/>
</FrameLayout>
Problema: como se puede ver, el comportamiento esperado sería tener el vacío TextView arriba para que aparezca centrado en la pantalla. En la vista previa del diseño en Eclipse, está bien. Solo cuando se agrega a root_view como un fragmento, FrameLayout no ocupará toda la pantalla.
root_container es azul, y FrameLayout es amarillento, ver a continuación con fines de depuración. ¿No debería el panel amarillo llenar toda la pantalla?!?!?!?
Si utiliza ScrollView, descargue esto: http://stackoverflow.com/questions/10211338/view-inside-scrollview-doesnt-take-all-place –