这是我的布局xml。
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/garae_scroll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/background"
android:fillViewport="true"
android:focusableInTouchMode="false" >
<RelativeLayout>
...
<com.handmark.pulltorefresh.library.PullToRefreshScrollView>
<LinearLayout/>
</com.handmark.pulltorefresh.library.PullToRefreshScrollView>
</RelativeLayout>
</ScrollView>
我已经在此链接中尝试过该解决方案:ScrollView Inside ScrollView
但是,它没有用。如何使用子项PullToRefreshScrollView?请帮助我。
如果我理解您的问题,您想在滚动视图中实现拉动以刷新。相反,要使用您正在使用的库,建议您实现SwipeRefreshLayouthttps://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.html它是一种布局,可以像Google+或Gmail的应用程序一样实现一键式刷新。
这是在您的xml中实现SwipeRefreshLayout
的示例:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
android:layout_width="match_parent" android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android" >
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipe_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/garae_scroll"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ScrollView>
</android.support.v4.widget.SwipeRefreshLayout>
</FrameLayout>
NOTE
强烈建议不要在滚动视图/列表视图中放置滚动视图/列表视图。第一个原因与性能有关,罗曼·盖伊(Romain Guy)解释说,在一个视频中https://www.youtube.com/watch?v=wDBM6wVEO70