Wednesday, 9 December 2020

Android WebView not shoing header bars or floating buttons

I have an Android WebView where I want to show a page, but certain elements of the page are not showing up.

Since its a work related page and you need an account to access it, I cannot share the link as it would not work.

On picture 1 (left) is my WebView that is not displaying the 2 header bars that can be seen on the picture 2 (right) and also in the middle there is a floating button that goes over the views, which is also not displayed in Android's WebView.
Picutre 2 is the page in a normal web browser but in the mobile view. I also tried opening the page normally via phone's browser and it also worked fine.

What it looks like What it should look like

Here is a simple WebView that produces the same error:

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        WebView myWebView = (WebView) findViewById(R.id.webview);
        myWebView.setWebViewClient(new MyWebViewClient());

        WebSettings webSettings = myWebView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webSettings.setLoadWithOverviewMode(true);
        webSettings.setUseWideViewPort(true);
        webSettings.setDomStorageEnabled(true);

        myWebView.loadUrl("https://secret.webpage.com");
    }

    private class MyWebViewClient extends WebViewClient {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            return false;
        }
    }
}

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

I have tried implementing custom Chromium Browser by implementing BaseChromeClient but that has also produced no results.

If there are questions about the webpage then I will provide answers as soon as I can.



from Android WebView not shoing header bars or floating buttons

No comments:

Post a Comment