What is the default layout background

I got a WebView that load an HTML file with a text. The problem is that the color inside the html and outside isn't the same. Here is a screenshot:

The Activity With the WebView

The HTML FIle is:

<html dir="rtl">
<head>
<title>About</title>
<meta content="text/html; charset=UTF-8" http-equiv="content-type"/>


<body bgcolor="#FFFFFF">
<p>This is a Testpp</p>
<p>See the problem.</p>
<p>last test:</p>
</body>
</html>

(If I remove the: bgcolor="#FFFFFF" color stays the same) Thanks!

79568 次浏览

Default color is black.

If you use style, go to "values/styles.xml" and there is solution of you issue. Now you can check bg color. About themes and styles : http://developer.android.com/guide/topics/ui/themes.html

EDIT :

Layout background color changing - Setting background colour of Android layout element

EDIT 2:

If in styles.xml is @android:style/Theme.Light your bg color is white.

To change your background (if this is in fact what you are looking to do):

in styles.xml

<style name = "MyDefaultStyle" parent = "@android:style/Theme">
<item name = "android:windowBackground">@drawable/default_drawable_bg</item>
</style>

and in your manifest

<application
android:name="MyApp"
android:theme="@style/MyDefaultStyle" >

The default background color for light theme is: #EEEEEE

Is almost white, but not completely.

It worked for me, hope its work for you.

UPDATE: In new versions you could be looking for #FAFAFA

Go to Manifest

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/MyMaterialTheme.NoActionBar">

You see the Theme is MyMaterialTheme.NoActionBar

So go to res -> values -> styles Click open in editor

Click on the pallette for the background color

This is your background color

So for me the default is #FFFAFAFA

When i put the suggested colors #EEEEEE or #FAFAFA, it worked on some phones, and on other phones it was off, so that's what I found with trial and error

You can use your theme's default background color by referencing:

?android:colorBackground

The default background color for light theme is: #e6FFFFFF