SwipeRefreshLayout скрыт за ActionBar с прозрачными строками состояния

У меня возникли проблемы с отображением моего SwipeRefreshLayout при использовании прозрачной навигации и строк состояния (уровень API 19). То есть в настоящее время он находится под строкой состояния (вверху экрана), когда я хочу, чтобы он находился под панелью действий.

ListView работает как положено. То есть содержимое правильно отображается за панелями навигации и не скрывается под строкой состояния или панелью действий.

При этом, если я добавлю свойство android:fitsSystemWindows="true" в свой относительный макет, SwipeRefreshLayout будет работать правильно. Но это делает мой список невидимым под прозрачными панелями навигации. Вместо этого панели навигации просто имеют цвет моего фона и не позволяют отображать содержимое из моего списка под ним.

Как я могу заставить ListView оставаться таким, как сейчас, а также сделать так, чтобы мой SwipeRefreshLayout был видимым (вместо того, чтобы быть скрытым под строкой состояния в верхней части экрана)?

Ниже мой макет:

<android.support.v4.widget.DrawerLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/drawer_layout"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:paddingTop="10dp"
            android:background="#ccc"
            android:clipToPadding="false">

            <android.support.v4.widget.SwipeRefreshLayout
                android:id="@+id/swipe_container"
                android:layout_width="match_parent"
                android:layout_height="match_parent">

            <FrameLayout
                android:id="@+id/container"
                android:paddingLeft="@dimen/activity_horizontal_margin"
                android:paddingRight="@dimen/activity_horizontal_margin"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:background="#ccc">

                <ListView
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:id="@+id/listView"
                    android:paddingTop="10dp"
                    android:fitsSystemWindows="true"
                    android:clipToPadding="false"
                    android:divider="@android:color/transparent"
                    android:layout_gravity="left|top" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:text="No Internet Connection"
                    android:id="@+id/noInternet"
                    android:textColor="@android:color/secondary_text_light"
                    android:layout_gravity="center" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textAppearance="?android:attr/textAppearanceMedium"
                    android:text="Pull To Refresh"
                    android:translationY="20dp"
                    android:id="@+id/nointernetSub"
                    android:textColor="@android:color/secondary_text_light"
                    android:layout_gravity="center" />

            </FrameLayout>

            </android.support.v4.widget.SwipeRefreshLayout>

        </RelativeLayout>

    <fragment android:id="@+id/navigation_drawer"
        android:layout_width="@dimen/navigation_drawer_width"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:name="com.package.app.NavigationDrawerFragment"
        tools:layout="@layout/fragment_navigation_drawer" />

</android.support.v4.widget.DrawerLayout>

person user3634770    schedule 14.05.2014    source источник
comment
Прошло много времени с вашего вопроса, но, возможно, вам все еще нужен ответ. Взгляните на это: stackoverflow.com/questions/24413680/   -  person Naroh    schedule 05.07.2014


Ответы (1)


Я бы рекомендовал использовать маржу

android:layout_marginTop="?android:attr/actionBarSize"
person Richard Olthuis    schedule 07.10.2015