Kishor Morais
Kishor Morais

Reputation: 13

swipe refresh is overriding scrolling the menu in my web page in webview

I'm setting up a web page inside web view. my web page have swipe down to refresh function.when my web page is in top, when i scroll drawer menu in my web page , swipe to refresh is occurring. how to solve this issue?

main activity layout code

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginBottom="45dp"
    android:orientation="vertical">

    <ProgressBar
        android:layout_width="match_parent"
        android:layout_height="10dp"
        android:id="@+id/progressBar"
        style="@style/Widget.AppCompat.ProgressBar.Horizontal"/>

<android.support.v4.widget.SwipeRefreshLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/swipe">

        <WebView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/homeWeb"
            android:layout_above="@id/navBar"/>


</android.support.v4.widget.SwipeRefreshLayout>

</LinearLayout>

MainActivity

swipe.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener(){        
  @Override           
  public void onRefresh() {          
    homeWeb.reload();              
  }      
});

Upvotes: 1

Views: 1058

Answers (1)

Tushar Lathiya
Tushar Lathiya

Reputation: 1048

Enable/Disable swipe refresh when do something with webview. Below method do same. try and let me know will it work or not.

swipe.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
                @Override
                public void onScrollChanged() {
                    swipe.setEnabled((homeWeb.getScrollY() == 0));
                }
            });

Upvotes: 1

Related Questions