首页 文章

SwipeRefreshLayout隐藏在ActionBar后面,带有透明状态栏

提问于
浏览
11

使用透明导航和状态栏(API级别19)时,我在查看SwipeRefreshLayout时遇到了一些问题 . 也就是说,它当前位于状态栏下(位于屏幕顶部),当我希望它位于操作栏下时 .

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>

1 回答

  • 4

    我建议使用保证金

    android:layout_marginTop="?android:attr/actionBarSize"
    

相关问题