The 100% CSS styling in Android WebView 4.4 is failing to display any content

When utilizing an Android webview to load a basic HTML page, I encountered an issue where the content div with 100% width and height was not visible on a Galaxy Nexus 4.4.2 device. This problem did not occur when viewed in a browser.

Below are the settings for the webview:

    setScrollContainer(false);
    setBackgroundColor(Color.RED);
    setHorizontalScrollBarEnabled(false);
    setHorizontalScrollbarOverlay(false);
    setVerticalScrollBarEnabled(false);
    setVerticalScrollbarOverlay(false);
    this.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

    WebSettings ws = getSettings();
    ws.setSupportZoom(false);
    ws.setJavaScriptEnabled(true);
    ws.setUseWideViewPort(true);
    ws.setLoadWithOverviewMode(true);
    ws.setCacheMode(WebSettings.LOAD_NO_CACHE);
    ws.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL);
    ws.setAllowFileAccess(true);
    ws.setAllowFileAccessFromFileURLs(true);

The sample HTML code is as follows:

<html>
 <head>
    <title>Title</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <meta http-equiv="cache-control" content="no-cache" />
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta id="myvp" name="viewport" content="width=400, height=300, initial-scale=1.0">
        <link rel="stylesheet" type="text/css" href="./main.css">
    </head>
    <body>
    <div class="component">
            <input type="text">
    </div>
    </body>
</html>

Furthermore, here is the CSS used:

body {
    background-color: blue;
}

.component {
    width: 100%;
    height: 100%;
    background-color: green;
    overflow: hidden;
}

Despite expecting a green box containing a text field, only the blue background of the body was visible. Adjusting the settings or replacing percentages with fixed values resulted in different issues, such as the inability to select the text field.

It seems that the component div may not be appearing due to a width/height issue when using percentages. Does anyone have insight into this problem and why text input is restricted?

Thank you

Answer №1

The issue we encountered was that we accidentally omitted calling the super method within onSizeChanged, causing it to be overwritten. By adding the line Super.onSizeChanged(w,h,oldw,oldh), we were able to resolve the problem successfully. Grateful for everyone's input and assistance.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Guide to positioning front layer in CSS3

I am currently working on a page and have added an "Under Construction" banner to indicate it is not yet finished. Could someone assist me in bringing the png to the forefront on this link? ...

What happens in the React tutorial when the clear fix is commented out and the appearance does not change?

Currently, I am working through the React tutorial and have encountered a question regarding their starter code: class Square extends React.Component { render() { return ( <button className="square"> {/* TODO */} </butto ...

Maintain the fixed position of the horizontal scroll bar

I'm facing an issue with a popup window that displays a frameset. Within one of the frames, I'm using jQuery tabs to show some text. The problem arises when trying to display long text or when resizing the window, causing the horizontal scroll t ...

Make sure to pause and wait for a click before diverting your

Having an issue with a search dropdown that displays suggestions when the search input is focused. The problem arises when the dropdown closes as soon as the input loses focus, which is the desired functionality. However, clicking on any suggestion causes ...

Tips for choosing the injected HTML's List Element (li) while ensuring it remains concealed

How do I hide the list item with iconsrc="/_layouts/15/images/delitem.gif" image when this div is injected by a first party and I am a third party trying to conceal it? $("<style> what should be inserted here ???? { display: none; } </style>") ...

Is there a way to eliminate the hover effect on a button within a navbar?

I'm currently working on a website using Angular and I have implemented a gray navbar with a hamburger icon that reveals a dropdown menu upon clicking. One of the menu items is "Projects," which when hovered over, displays individual links to various ...

Ways to eliminate excess space at the top of a page while utilizing float elements

After doing some research online, I've come across advice on how to remove the space at the top of a web page which usually involves setting the margin and padding of the body element to 0: body { margin: 0; padding: 0; } You can find more i ...

What might be causing the sudden shifts in element positions during TweenLite animation?

I have created a demo of my code in this JSFiddle and also included it below. The issue I am facing occurs in Google Chrome, so I would recommend using that browser to replicate and fix the bug. Please note that the code is a snippet from a larger project ...

The Google Directions API transit consistently returns a "ZERO_RESULTS" error whenever a Persian word is included in the URL

I have been struggling to retrieve the Longitude and Latitude from a city name. Despite searching and testing numerous source codes, none of them have been helpful. Then, I stumbled upon this link: http://maps.googleapis.com/maps/api/geocode/json?address= ...

Creating a smooth transition effect between two different layouts through animation

I've been working on creating a smooth animation that transitions between two layouts with a delay in between. The first layout is the main layout, while the second layout features a simple linear layout with a text view and red background (reminiscen ...

Increase jQuery value by X each time it is clicked

I'm trying to create a custom next/prev navigation where clicking the "next" button will animate the margin left by X on each click until reaching the end (-320px), with a similar method for the back button. Here is the JavaScript code I've been ...

JQuery's find() method followed by length/size() is resulting in a return

I'm running into an issue with dynamically created divs. Here's how they are created: // Loop through and append divs to #result_main_search $("#result_main_search").append('<div class="singleresult_main_search"> <a href="http:// ...

Is it possible to enable CSS margins to collapse across a fieldset boundary in any way?

One interesting CSS behavior is that adjacent vertical margins typically collapse into one another. In other words, the space between elements will be equal to the larger margin instead of the sum of both margins. Interestingly, fieldset elements do not f ...

Issue with Bootstrap 5 spinner's lack of motion in Firefox browser

Essentially, the issue is that a very simple Bootstrap 5 spinner does not spin in Firefox. It works fine in Chromium and all other Bootstrap components work well in Firefox as well. Here is the html code (identical to Bootstrap docs): <div class=&q ...

What is the reason for not being able to align breadcrumb text to the right

This section contains HTML code and CSS for a breadcrumb container. The issue is that the breadcrumb is currently displayed on the left side. How can the breadcrumb be right-aligned? .breadcrumb-container { font-family: "Work Sans", sans-serif; ...

What is the best way to ensure consistent display of a bootstrap 4 card structure on both mobile and desktop devices?

I'm attempting to make the bootstrap card look the same on mobile as it does on desktop, but I haven't been able to find a solution online. No snippets have been helpful! Below is a comparison of the appearance of the bootstrap v4 card: Desktop ...

What is the best way to incorporate TypeScript variables into CSS files?

In my Angular project, I am aiming to utilize a string defined in Typescript within a CSS file. Specifically, I want to set the background image of a navbar component using a path retrieved from a database service. Although I came across suggestions to use ...

Accordion nested within another accordion

I am facing a challenge while trying to nest an accordion within another accordion. The issue is that the nested accordion only expands as much as the first accordion, requiring additional space to display its content properly. Any assistance with resolvin ...

What is the best way to arrange a row of names (Strings) horizontally and turn them into clickable links?

Currently, I am seeking a solution to showcase a horizontal list of names in my Android application (potentially using a TextView) that are all clickable. These names are retrieved from an online database along with their unique id, which leads to their in ...

What is the best way to ensure that custom JavaScript and CSS files in Sphinx are always loaded with the most recent changes

Within the configuration file conf.py for Sphinx, I have specified the following: html_css_files = ['css/custom.css'] html_js_files = ['js/custom.js'] However, any alterations made to custom.js or custom.css do not immediately appear i ...