Search code examples
androidwebviewvertical-scrolling

Need to disable only vertical scrolling in web view android


In XML, I given android:scrollbars="none" to web view

<WebView
    android:id="@+id/wvProgress"
    android:layout_width="match_parent"
    android:scrollbars="none"
    android:layout_height="match_parent" />

In java file,

wvProgress.setVerticalScrollBarEnabled(false);

but, still some vertical scrollbar is not disable and some extra white space is display below web view. Show screenshot


Solution

  • After tried multiple ways, finally I found solution for my questions - show only horizontal scroll and remove vertical scroll in webview.

    First, I have set height and width of webview which I required.Then put webview in horizontal scrollview. So,I found vertical scrolling is remove and only horizontal scrolling is available. For better UI performance and scrolling I put horizontal scrollview in framelayout.

    My Source code show below:-

     <FrameLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">
    
                <HorizontalScrollView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:scrollbars="none">
    
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent">
    
                        <WebView
                            android:id="@+id/wvProgress"
                            android:minHeight="0dp"
                            android:layout_width="@dimen/_800dp"
                            android:layout_height="@dimen/_300dp" />
                    </LinearLayout>
                </HorizontalScrollView>
    
            </FrameLayout>