The Android Webview is experiencing difficulties with loading CSS styles and displaying the blockquote font color effect

I am facing an issue with loading HTML content in CSS through Android WebView. Despite having the code executed, I don't see any observable changes in font color for the text inside blockquote tags

Here is the HTML code:

<html>
    <head>
        <title>Example</title>
        <link rel="stylesheet" type="text/css" href="file:///android_asset/style.css" />
    </head>
        <blockquote>拜年根本係學溝通同交際#hehe#</blockquote>
        <br/><br/>唔明點解去完親戚屋企拜年 過幾日親戚要黎返我屋企再拜過年 [banghead]
    </body>
</html>

CSS:

@CHARSET "UTF-8";

blockquote{
color:#d4d3d3
  }

Actual android code

viewHolder.txContent = (WebView) v.findViewById(R.id.replycontent);
        WebSettings settings = viewHolder.txContent.getSettings();
        settings.setDefaultTextEncodingName("utf-8");

        settings.setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
        viewHolder.txContent.setFocusable(false);
        viewHolder.txContent.setClickable(true);
        viewHolder.txContent.setBackgroundColor(Color.parseColor("#00FFFFFF"));




String htmlPreffix = "<html><head><title>Example</title><link rel=\"stylesheet\" type=\"text/css\" href=\"file:///android_asset/style.css\" /></head>";
            String htmlSuffixString = "</body></html>";

            System.out.println("htmlParsed");
            System.out.println(htmlPreffix + htmlParsed + htmlSuffixString);
            viewHolder.txContent.loadDataWithBaseURL(null, htmlParsed, "text/html", "utf-8", null);

Answer №1

One essential element you've overlooked is the <body> tag that should be included at the beginning of your code.

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

Tips for preventing the use of website URLs as variables in jQuery ajax() calls:

Having some trouble. For example: $(document).ready(function () { $("#btnSend").click(function () { var noti_p = { url: "Pusher_Controller.ashx", data: "&appname=" + $("#selt1").val() + "&title=" + $("#title"). ...

Duplicate the canvas onto a new canvas

One of the functions I am using involves copying an old canvas to a new canvas. Here is the code snippet for this functionality: function cloneCanvas(oldCanvas) { //create a new canvas var newCanvas = document.createElement('canvas&a ...

Deselect all checkboxes other than the daily selection

I recently designed an E-commerce website that includes a package customization feature where users can modify their packages. The initial question presents three radio button options: 1. Daily 2. Weekly 3. Monthly If the user selects 'daily&apos ...

Is it possible to dynamically render css using Express.js?

I have a need to dynamically generate CSS with each request. For example, in my Express.js application, I've set up a route like this: /clients/:clientId/style.css When a matching request is received, I want to retrieve the Client from the reposito ...

Displaying all items in the flexbox in a single row by decreasing the width of each individual box

After some tweaking, I now have a lineup of boxes styled like this: Check out the code in action on Codepen. Unfortunately, StackOverflow doesn't display it accurately. This is the CSS I implemented: @font-face { font-family: "Heebo-Light"; src: ...

Is it possible to block the installation of an app on a specific device running on Android?

I am working on an enterprise application that should only be installed on 50 specific mobile devices with their IMEI information. It is crucial that my app is not accessible or installable on any other device, even if a user obtains the apk file. I have ...

Issue with React/Next.js input field rejecting commas

I'm experiencing a problem with an input field in my React application that was developed using Next.js. The issue arises specifically when using an iPad device, where the input field behaves inconsistently when dealing with commas. When using deskto ...

Is it possible to modify the CSS styling in React using the following demonstration?

I am attempting to create an interactive feature where a ball moves to the location where the mouse is clicked. Although the X and Y coordinates are being logged successfully, the ball itself is not moving. Can anyone help me identify what I might be overl ...

Inserting a PHP variable ($username) into a form field

<form method="POST"> <h1>Contact Us</h1> <span><h2 class="required">*Required</h2></span> <div class="input-group"> <label class="sr-only">First Name</label> <input class="text" ...

Retrieving data from dynamic form components in Angular

I am currently utilizing a back-end API to retrieve flight data, which I then iterate through and exhibit. The layout of my template code is as follows... <form novalidate #form="ngForm"> <div class="flight-table"> <header fxLayou ...

Is it possible to implement a custom radio tab index without using JavaScript

Is it possible to apply the tabindex attribute on custom radio buttons, hide the actual input element, and use keyboard shortcuts like Tab, Arrow Up, and Arrow Down to change the value? Check out this example on StackBlitz ...

`Can you guide me on the proper path for designing this website layout?`

As I embark on creating my first website, I have a specific vision in mind. I want the full display on a computer screen to show all the information and links without any need for scrolling. However, when the window is resized to smaller screens, I would l ...

Is it necessary for me to employ MetaTag http-equiv in conjunction with DTD XHTML 1.0 Transitional//EN?

Currently using Asp.net for my project. In the document, I have included the following: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> I am wondering if it is necessary to a ...

There is a slight gap between the svg element and the path

Here is the size of my path tag (g tag is same size) https://i.sstatic.net/Huk8j.png This is the size of my SVG tag https://i.sstatic.net/VBXQi.png There is a gap between them. These are the inline attributes... <svg preserveAspectRatio="none" cla ...

Combining CSS documents

In order to improve page load speed, I need to consolidate multiple CSS files into one large file. Will the styles function properly if I merge them all together, or are there potential issues when combining multiple CSS files? My software is built in Ja ...

What is the best method for creating React Native applications?

I am a beginner in the world of react-native. Currently, I am working on my first app using react-native and looking to establish the most effective project structure for its development. So far, I have created components in the root folder, but I am unsu ...

Using Bootstrap to horizontally align cards in a single row

When rendering the 4 items in a row using a for loop, I encounter an issue where the first line renders 4 items correctly but subsequent items are rendered on separate lines. code <div class="card-group"> {% for item in wt %} <di ...

Generate a unique border using jQuery randomization techniques

I've been experimenting with creating a random number and having the border-radius of my div change on every pageload: <script> $(".card-body").each(function(){ var rand = Math.floor(Math.random() * 100) + 1; $(this).css( { borderRadius: rand ...

Google Maps Marker disappeared upon relocation to the current application

After reading several articles on missing markers, I'm still facing a unique issue that doesn't seem to have a clear solution. The problem arises when attempting to render a basic map with just one marker and a fixed location. Despite Chrome dev ...

Adjust the parent container to perfectly accommodate the child element

Is there a way to resize the container box to fit its dynamic content without using JavaScript? Here is the sample code for the problem: <div id="container"> <div id="content"></div> </div> #container { position: relativ ...