0

I'm having an issue with the SwipeRefreshLayout. I have a layout within two GridView's and every time I scroll upward in the GridView the swipe to refresh layout is tiggered and you can never scroll back to the top of the layout. Anyone have any ideas?

I checkedthis and this but that isn't for a GridView. Please help if you can

SwipeRefreshLayout

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

<LinearLayout android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:baselineAligned="false"
    android:orientation="vertical">


    <GridView
        android:id="@+id/GridView1"
        android:layout_width="wrap_content"
        android:layout_height="31dp"
        android:numColumns="1"
        android:padding="1dp" />

    <GridView
        android:id="@+id/GridView2"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:footerDividersEnabled="false"
        android:numColumns="3"
        android:padding="1dp" />

</LinearLayout>


</android.support.v4.widget.SwipeRefreshLayout>
Hannes
  • 223
  • 1
  • 3
  • 9

2 Answers2

0

Try adding android:fillViewport="true" to your SwipeRefreshLayout.

Marcus
  • 164
  • 1
  • 13
0

Give your Linear layout id as android:id="@+id/parentPanelLL" and write below code in your activity...

swipe_container.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
        @Override
        public void onScrollChanged() {
            if (parentPanelLL.getScrollY() == 0) {
                swipe_container.setEnabled(true);
            } else {
                swipe_container.setEnabled(false);
            }
        }
    });

try this...

Rohan Shukla
  • 533
  • 1
  • 4
  • 16