Android Fragment does not respect match_parent as height

Извините за огромный дамп кода, но я действительно запутался.

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;

Notes: mRootView - это глобальная ViewGroup, с этим проблем нет, я полагаю. PlacesFragment - это ListFragment.

Макеты:

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>

Проблема: Как вы видите, ожидаемое поведение заключается в том, чтобы пустой TextView вверху отображался по центру экрана. На предварительном просмотре дизайна в Eclipse все в порядке. Только при добавлении к root_view как фрагмента FrameLayout не заполняет весь экран.

root_container синий, а FrameLayout желтоватый, см. ниже для отладки. Разве желтая панель не должна заполнять весь экран?!?!?!?!???

enter image description here

43
задан ThinkingStiff 29 June 2012 в 07:33
поделиться