【发布时间】:2016-07-12 13:41:20
【问题描述】:
我有这个布局基础:
<RelativeLayout
android:id="@+id/list_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_list_container"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout
android:id="@+id/list_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/background" />
</android.support.v4.widget.SwipeRefreshLayout>
</RelativeLayout>
在这个片段创建过程中,我添加了一个特定的列表:
<ListView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:divider="@color/list_divider"
android:dividerHeight="1px" />
所以当我点击红色区域(列表视图之外)时,会调用监听器:
mSwipeContainer.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
...
}
});
那么,为什么要调用这个监听器,我可以避免这种行为吗?
【问题讨论】:
-
将
android:layout_height="wrap_content"更改为android:layout_height="match_parent"或在SwipeRefreshLayout中使用wrap_content作为高度 -
SwipeRefresh 设置为匹配内容,因此红色区域是其中的一部分
-
android:layout_height="wrap_content" -
我已经用 wrap_content 更新了我的 XML(见上文)。结果是一样的。
-
更改相对布局的高度,以换行。
标签: android listview swiperefreshlayout