1

i have a layout with swipeaRefreshLayout and a Toolbar(Both from v4 and v7 using v-21), but when i start the app the listview its hide, i only can see the toolbar like a actionbar. This is my code:

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="?attr/colorPrimary" />

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


            <ListView
                android:id="@+id/questionList"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/swipe_container"
                android:layout_gravity="center_horizontal"
                android:layout_toEndOf="@id/swipe_container"
                android:background="#686868"
                android:visibility="visible" />

            <com.shamanland.fab.FloatingActionButton
                android:id="@+id/btnNew"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_alignParentEnd="true"
                android:layout_marginBottom="50dp"
                android:layout_marginRight="32dp" />

            <LinearLayout
                android:id="@+id/emptyData"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_gravity="center"
                android:background="#686868"
                android:clickable="true"
                android:orientation="vertical"
                android:visibility="gone">

                <TextView
                    android:id="@+id/textView"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:padding="4dp"
                    android:text="No hay elementos disponibles"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:textColor="@android:color/white"
                    android:textStyle="bold" />

                <ImageView
                    android:id="@+id/imageView"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:paddingBottom="4dp"
                    android:src="@android:drawable/ic_dialog_email" />
            </LinearLayout>
    </android.support.v4.widget.SwipeRefreshLayout>
</RelativeLayout>
4

1 回答 1

4

SwipeRefreshLayout 只能有一个子视图,将其内容包装在线性布局中。那应该可以解决您的问题

于 2014-10-20T23:41:48.747 回答