Home keyboard_arrow_right Questions keyboard_arrow_right #Android
How to resolve Scroll and Touch issue in nested scroll webview android
question
0
sangram naik
July 5, 2018 (edited)
asked 1 year, 3 months ago
viewed 371 times

When I tried to scroll (up/down) the inner scroll, the outer scroll is moving in webview for which it is being refreshed by "SwipeRefreshLayout". Please provide the best way to handle that problem!

this is my xml code

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/constraintLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">
    <android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/swipeContainer"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">
    <!--<WebView  xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/webView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >
    </WebView>-->
        <android.support.v7.widget.LinearLayoutCompat
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">
            <im.delight.android.webview.AdvancedWebView
                android:id="@+id/webView"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent" />
        </android.support.v7.widget.LinearLayoutCompat>
    </android.support.v4.widget.SwipeRefreshLayout>

    <ProgressBar
        android:id="@+id/progressBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>

advance webview is my custom webview github link is https://github.com/delight-im/Android-AdvancedWebView

1 Answer
Android Pal @pal July 9, 2018

Ah.. WebViews and scrolling.. One rule of thumb is you make your WebView's height WRAP_CONTENT. Especially if you're handling short pages, this way you can have better control of its scrolling (maybe wrap it in a ScrollView).


If you're using a ScrollView you can easily detect touch/scroll events and trigger your SwipeRefreshLayout programmatically.

0

sign in Sign in to add your reply or comment.

delete_forever
Careful now...
Doing this you will loose this information and the action cannot be undone.
This action cannot be undone.
cancel