SwipeRefreshLayout is hidden behind ActionBar with transparent status bars
Asked Answered
R

1

11

I'm having some trouble making my SwipeRefreshLayout visible when using transparent navigation, and status bars (API Level 19). That is to say, its currently under the status bar (at the top of the screen), when I want it to be under the actionbar.

The ListView is working as expected. That is, the content is properly shown behind the navigation bars, and does not get hidden under the status bar, or actionbar.

With this being said, if I add the android:fitsSystemWindows="true" property to my relative layout, the SwipeRefreshLayout works properly. But, doing this makes my listview not visible under the transparent navigation bars. Instead, the navigation bars are simply the color of my background, and do not allow content from my listview to be shown under it.

How can I get the ListView to stay how it is now, and also get my SwipeRefreshLayout to be visible (instead of being hidden under the status bar, at the top of the screen)?

Below is my layout:

<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>
Ravage answered 14/5, 2014 at 2:8 Comment(1)
It has been a long time since your question, but maybe you still need an answer. Take a look at this: #24414180Gearhart
C
4

I would recommend using a margin

android:layout_marginTop="?android:attr/actionBarSize"
Chive answered 7/10, 2015 at 11:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.