5

Here is my layout 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>

I already tried the solution in this link: ScrollView Inside ScrollView

However, it didn't work. How can do use child PullToRefreshScrollView?? Please help me.

Community
  • 1
  • 1
user3517556
  • 51
  • 1
  • 1
  • 4

1 Answers1

10

If I understand your question, you want to implement a Pull to refresh in your Scrollview. Instead, to use the library you are using, I would suggest you to implement a SwipeRefreshLayout https://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.html It is a layout that implements a pull-to-refresh like in the application of Google+ or Gmail.

Here's an example implementing SwipeRefreshLayout in your xml:

    <?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

It is highly not recommended to put a Scrollview/Listview inside a Scrollview/Listview. The first reason is about the performance and Romain Guy explains that in one video https://www.youtube.com/watch?v=wDBM6wVEO70

Dr.jacky
  • 3,341
  • 6
  • 53
  • 91
Hugo
  • 295
  • 2
  • 15