添加了swiperefreshlayout后,按钮消失了

时间:2016-11-22 07:39:38

标签: android listview layout

我在listview的底部有一个listview和两个按钮的布局。一切正常,直到我为listview添加了swiperefreshlayout。

我的代码如下。

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#FFF"
>
<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:id="@+id/search_bar"
    android:background="@color/colorPrimaryDark"
    android:orientation="vertical"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    >

    <EditText
        android:id="@+id/keyword_editText"
        android:layout_width="fill_parent"
        android:layout_height="30dp"
        android:background="@drawable/search_edit_text"
        android:hint="Keyword"
        android:textColorHint="@color/list_item_title"
        android:textColor="#000"
        android:layout_centerVertical="true"
        android:maxLines="1"/>


</RelativeLayout>
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/listView_layout"
    android:orientation="vertical"
    android:layout_below="@+id/search_bar"

    >

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

    <ListView
        android:layout_width="wrap_content"
        android:layout_height="0dip"
        android:layout_weight="1"
        android:id="@+id/RsListView"
        android:dividerHeight="1dp"
        android:divider="#D3D3D3"/>

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

    <LinearLayout
        android:id="@+id/test"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        >
        <Button
            android:id="@+id/req_history_button"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Request History"
            android:layout_weight="1"
            android:background="@drawable/request_history_button"
            android:textColor="@drawable/button_text_color"
            />
        <Button
            android:id="@+id/apprv_history_button"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Approval History"
            android:layout_weight="1"
            android:background="@drawable/approval_history_button"
            android:textColor="@drawable/button_text_color"
            />
    </LinearLayout>

</LinearLayout>

很抱歉在这里转储我的代码,因为我无法通过其他任何方式让您了解我的代码。

请帮忙

1 个答案:

答案 0 :(得分:1)

layout_weight内,通常所有孩子都会根据方向拥有均匀的尺寸。但是,当您希望一个孩子占用少量的地方而另一个孩子来填补其余部分时,您可能会对android:layout_weight="1"参数感兴趣。如果应该填充空间的孩子获得android:layout_weight="1",那么它将占据空间,为其他视图创造空间。

要查看按钮,请将SwipeRefreshLayout添加到android:layout_height="0dp"并设置{{1}}。这将使您的按钮可见。