【发布时间】:2016-03-14 15:59:44
【问题描述】:
我通过以下方式实现了 SwipeRefreshLayout:
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipeRefreshLayout"
android:layout_width="wrap_content"
android:layout_height="200dp">
<RelativeLayout
android:id="@+id/profile_pic_name"
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="@drawable/profile_bg"
android:gravity="center"
android:paddingBottom="2dp"
android:clickable="true"
android:paddingTop="2dp">
<ImageView
android:id="@+id/profile"
android:layout_width="200dp"
android:layout_height="150dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:paddingBottom="2dp"
android:paddingTop="2dp"
android:src="@drawable/user_default" />
<TextView
android:id="@+id/profile_name"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/image_profile"
android:gravity="center_horizontal"
android:text="Hi Member"
android:textAllCaps="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/White"
android:textSize="@dimen/main_menu_name_text_size"
android:textStyle="bold" />
</RelativeLayout>
</android.support.v4.widget.SwipeRefreshLayout>
在java代码中我只是设置了以下内容:
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
loadData();
}
});
但是当我触摸我的视图的结束时,例如 profile_name 或 RelativeLayout 的结束。它刷新了屏幕。
有人可以帮忙找出解决方案,为什么它不用刷卡就能自动刷新吗??
【问题讨论】:
-
能否尝试将您的滑动刷新高度和宽度设置为 match_parent
-
但是还有其他视图...我无法将其设置为匹配父级。
-
其他视图在相对布局内:您可以在此处设置整体布局所需的任何高度和宽度。
标签: android android-layout swiperefreshlayout