Android WebView - scrollbar don't fill the layout_height












7















I have a WebView with large text content.
I'm using the following WebView settings:



    settings.setJavaScriptEnabled(true);
settings.setLoadWithOverviewMode(true);
settings.setUseWideViewPort(true);
settings.setSupportZoom(false);
settings.setBuiltInZoomControls(false);
webview.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
webview.setScrollbarFadingEnabled(false);


The Html viewport settings are:



<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />


The problem is that the scrollbar is going outside the layout, as follow:





My Android Layout is:



<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="@color/colorPrimary"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

<LinearLayout
android:id="@+id/frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent">


<WebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="match_parent" />


</LinearLayout>
</LinearLayout>









share|improve this question

























  • Are you able to scroll the last line of text or its hiding behind bottom menu buttons ?

    – Anand Phadke
    Nov 22 '18 at 12:57











  • I can go to the last line of Html content (text) but when I'm there the scrollbar is gone.

    – Apopei Andrei Ionut
    Nov 22 '18 at 13:21











  • I think removing content=user-scalable=no or setting it to yes from your html viewport settings should do the trick.

    – dglozano
    Nov 28 '18 at 0:19











  • the bounty is about to end give it to the closest answer or it all goes to waste

    – Pemba Tamang
    Dec 4 '18 at 10:22
















7















I have a WebView with large text content.
I'm using the following WebView settings:



    settings.setJavaScriptEnabled(true);
settings.setLoadWithOverviewMode(true);
settings.setUseWideViewPort(true);
settings.setSupportZoom(false);
settings.setBuiltInZoomControls(false);
webview.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
webview.setScrollbarFadingEnabled(false);


The Html viewport settings are:



<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />


The problem is that the scrollbar is going outside the layout, as follow:





My Android Layout is:



<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="@color/colorPrimary"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

<LinearLayout
android:id="@+id/frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent">


<WebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="match_parent" />


</LinearLayout>
</LinearLayout>









share|improve this question

























  • Are you able to scroll the last line of text or its hiding behind bottom menu buttons ?

    – Anand Phadke
    Nov 22 '18 at 12:57











  • I can go to the last line of Html content (text) but when I'm there the scrollbar is gone.

    – Apopei Andrei Ionut
    Nov 22 '18 at 13:21











  • I think removing content=user-scalable=no or setting it to yes from your html viewport settings should do the trick.

    – dglozano
    Nov 28 '18 at 0:19











  • the bounty is about to end give it to the closest answer or it all goes to waste

    – Pemba Tamang
    Dec 4 '18 at 10:22














7












7








7








I have a WebView with large text content.
I'm using the following WebView settings:



    settings.setJavaScriptEnabled(true);
settings.setLoadWithOverviewMode(true);
settings.setUseWideViewPort(true);
settings.setSupportZoom(false);
settings.setBuiltInZoomControls(false);
webview.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
webview.setScrollbarFadingEnabled(false);


The Html viewport settings are:



<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />


The problem is that the scrollbar is going outside the layout, as follow:





My Android Layout is:



<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="@color/colorPrimary"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

<LinearLayout
android:id="@+id/frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent">


<WebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="match_parent" />


</LinearLayout>
</LinearLayout>









share|improve this question
















I have a WebView with large text content.
I'm using the following WebView settings:



    settings.setJavaScriptEnabled(true);
settings.setLoadWithOverviewMode(true);
settings.setUseWideViewPort(true);
settings.setSupportZoom(false);
settings.setBuiltInZoomControls(false);
webview.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
webview.setScrollbarFadingEnabled(false);


The Html viewport settings are:



<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />


The problem is that the scrollbar is going outside the layout, as follow:





My Android Layout is:



<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="@color/colorPrimary"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

<LinearLayout
android:id="@+id/frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent">


<WebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="match_parent" />


</LinearLayout>
</LinearLayout>






android webview android-webview android-browser android-websettings






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 '18 at 13:20









Ali

1




1










asked Nov 22 '18 at 12:53









Apopei Andrei IonutApopei Andrei Ionut

154421




154421













  • Are you able to scroll the last line of text or its hiding behind bottom menu buttons ?

    – Anand Phadke
    Nov 22 '18 at 12:57











  • I can go to the last line of Html content (text) but when I'm there the scrollbar is gone.

    – Apopei Andrei Ionut
    Nov 22 '18 at 13:21











  • I think removing content=user-scalable=no or setting it to yes from your html viewport settings should do the trick.

    – dglozano
    Nov 28 '18 at 0:19











  • the bounty is about to end give it to the closest answer or it all goes to waste

    – Pemba Tamang
    Dec 4 '18 at 10:22



















  • Are you able to scroll the last line of text or its hiding behind bottom menu buttons ?

    – Anand Phadke
    Nov 22 '18 at 12:57











  • I can go to the last line of Html content (text) but when I'm there the scrollbar is gone.

    – Apopei Andrei Ionut
    Nov 22 '18 at 13:21











  • I think removing content=user-scalable=no or setting it to yes from your html viewport settings should do the trick.

    – dglozano
    Nov 28 '18 at 0:19











  • the bounty is about to end give it to the closest answer or it all goes to waste

    – Pemba Tamang
    Dec 4 '18 at 10:22

















Are you able to scroll the last line of text or its hiding behind bottom menu buttons ?

– Anand Phadke
Nov 22 '18 at 12:57





Are you able to scroll the last line of text or its hiding behind bottom menu buttons ?

– Anand Phadke
Nov 22 '18 at 12:57













I can go to the last line of Html content (text) but when I'm there the scrollbar is gone.

– Apopei Andrei Ionut
Nov 22 '18 at 13:21





I can go to the last line of Html content (text) but when I'm there the scrollbar is gone.

– Apopei Andrei Ionut
Nov 22 '18 at 13:21













I think removing content=user-scalable=no or setting it to yes from your html viewport settings should do the trick.

– dglozano
Nov 28 '18 at 0:19





I think removing content=user-scalable=no or setting it to yes from your html viewport settings should do the trick.

– dglozano
Nov 28 '18 at 0:19













the bounty is about to end give it to the closest answer or it all goes to waste

– Pemba Tamang
Dec 4 '18 at 10:22





the bounty is about to end give it to the closest answer or it all goes to waste

– Pemba Tamang
Dec 4 '18 at 10:22












3 Answers
3






active

oldest

votes


















1














I fixed the issue by adding the following on the WebView layout:



android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"





share|improve this answer
























  • can u explain how does layout_alignParentTop, layout_alignParentLeft, layout_alignParentStart will work inside LinearLayout

    – Nilesh Rathod
    Nov 29 '18 at 4:26











  • yeah odd........

    – Pemba Tamang
    Dec 4 '18 at 10:22



















1














try this :-



<WebView android:layout_width="fill_parent" 
android:layout_height="fill_parent"
android:id="@+id/webView" />


i fix this issue with this code






share|improve this answer
























  • fill_parent is deprecated

    – Nilesh Rathod
    Nov 29 '18 at 4:24



















0














You can add padding to parent layout



    <WebView android:layout_width="match_parent" 
android:layout_height="match_parent"
android:id="@+id/webView"
android:padding="3dp"/>





share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53431492%2fandroid-webview-scrollbar-dont-fill-the-layout-height%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    I fixed the issue by adding the following on the WebView layout:



    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"





    share|improve this answer
























    • can u explain how does layout_alignParentTop, layout_alignParentLeft, layout_alignParentStart will work inside LinearLayout

      – Nilesh Rathod
      Nov 29 '18 at 4:26











    • yeah odd........

      – Pemba Tamang
      Dec 4 '18 at 10:22
















    1














    I fixed the issue by adding the following on the WebView layout:



    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"





    share|improve this answer
























    • can u explain how does layout_alignParentTop, layout_alignParentLeft, layout_alignParentStart will work inside LinearLayout

      – Nilesh Rathod
      Nov 29 '18 at 4:26











    • yeah odd........

      – Pemba Tamang
      Dec 4 '18 at 10:22














    1












    1








    1







    I fixed the issue by adding the following on the WebView layout:



    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"





    share|improve this answer













    I fixed the issue by adding the following on the WebView layout:



    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 28 '18 at 8:40









    Apopei Andrei IonutApopei Andrei Ionut

    154421




    154421













    • can u explain how does layout_alignParentTop, layout_alignParentLeft, layout_alignParentStart will work inside LinearLayout

      – Nilesh Rathod
      Nov 29 '18 at 4:26











    • yeah odd........

      – Pemba Tamang
      Dec 4 '18 at 10:22



















    • can u explain how does layout_alignParentTop, layout_alignParentLeft, layout_alignParentStart will work inside LinearLayout

      – Nilesh Rathod
      Nov 29 '18 at 4:26











    • yeah odd........

      – Pemba Tamang
      Dec 4 '18 at 10:22

















    can u explain how does layout_alignParentTop, layout_alignParentLeft, layout_alignParentStart will work inside LinearLayout

    – Nilesh Rathod
    Nov 29 '18 at 4:26





    can u explain how does layout_alignParentTop, layout_alignParentLeft, layout_alignParentStart will work inside LinearLayout

    – Nilesh Rathod
    Nov 29 '18 at 4:26













    yeah odd........

    – Pemba Tamang
    Dec 4 '18 at 10:22





    yeah odd........

    – Pemba Tamang
    Dec 4 '18 at 10:22













    1














    try this :-



    <WebView android:layout_width="fill_parent" 
    android:layout_height="fill_parent"
    android:id="@+id/webView" />


    i fix this issue with this code






    share|improve this answer
























    • fill_parent is deprecated

      – Nilesh Rathod
      Nov 29 '18 at 4:24
















    1














    try this :-



    <WebView android:layout_width="fill_parent" 
    android:layout_height="fill_parent"
    android:id="@+id/webView" />


    i fix this issue with this code






    share|improve this answer
























    • fill_parent is deprecated

      – Nilesh Rathod
      Nov 29 '18 at 4:24














    1












    1








    1







    try this :-



    <WebView android:layout_width="fill_parent" 
    android:layout_height="fill_parent"
    android:id="@+id/webView" />


    i fix this issue with this code






    share|improve this answer













    try this :-



    <WebView android:layout_width="fill_parent" 
    android:layout_height="fill_parent"
    android:id="@+id/webView" />


    i fix this issue with this code







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 28 '18 at 15:32









    Harpreet SinghHarpreet Singh

    112




    112













    • fill_parent is deprecated

      – Nilesh Rathod
      Nov 29 '18 at 4:24



















    • fill_parent is deprecated

      – Nilesh Rathod
      Nov 29 '18 at 4:24

















    fill_parent is deprecated

    – Nilesh Rathod
    Nov 29 '18 at 4:24





    fill_parent is deprecated

    – Nilesh Rathod
    Nov 29 '18 at 4:24











    0














    You can add padding to parent layout



        <WebView android:layout_width="match_parent" 
    android:layout_height="match_parent"
    android:id="@+id/webView"
    android:padding="3dp"/>





    share|improve this answer




























      0














      You can add padding to parent layout



          <WebView android:layout_width="match_parent" 
      android:layout_height="match_parent"
      android:id="@+id/webView"
      android:padding="3dp"/>





      share|improve this answer


























        0












        0








        0







        You can add padding to parent layout



            <WebView android:layout_width="match_parent" 
        android:layout_height="match_parent"
        android:id="@+id/webView"
        android:padding="3dp"/>





        share|improve this answer













        You can add padding to parent layout



            <WebView android:layout_width="match_parent" 
        android:layout_height="match_parent"
        android:id="@+id/webView"
        android:padding="3dp"/>






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 29 '18 at 9:07









        Uma AchantaUma Achanta

        2,13221135




        2,13221135






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53431492%2fandroid-webview-scrollbar-dont-fill-the-layout-height%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            If I really need a card on my start hand, how many mulligans make sense? [duplicate]

            Alcedinidae

            Can an atomic nucleus contain both particles and antiparticles? [duplicate]