83

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!

Johnny Five
  • 987
  • 1
  • 14
  • 29
elichai2
  • 1,365
  • 3
  • 14
  • 28

6 Answers6

183

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

cutiko
  • 9,887
  • 3
  • 45
  • 59
  • 4
    It's the #EEEEEE still in android studio latest version. Thumbs up for this answer, thank you! – XIII Mar 15 '16 at 11:56
  • I have found my self that in later API version it changes, would you be so kind to check if it any difference between 21 and below please? Maybe I did something wrong with my project – cutiko Mar 15 '16 at 21:24
  • 6
    #FAFAFA +1 for me, emulator API 25, Theme.AppCompat.Light.NoActionBar – Lou Morda Dec 20 '18 at 22:43
  • Thank you! May I ask where you can find this information, just in case it changes in the future? – null_awe Nov 28 '20 at 04:45
  • @null_awe is either an image editing tool or is it a source code – cutiko Nov 28 '20 at 17:53
124

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

?android:colorBackground
Cristan
  • 12,083
  • 7
  • 65
  • 69
32

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" >
invertigo
  • 6,336
  • 5
  • 39
  • 64
14

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

Jaad Chacra
  • 549
  • 7
  • 12
1

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.

Community
  • 1
  • 1
TN888
  • 7,659
  • 9
  • 48
  • 84
  • Thanks, but the styles.xml just saying which them is it(default:Theme.Light and API14:Theme.Holo.Light.DarkActionBar) and i want to know which background color is in that themes.(it isn't black) thanks! – elichai2 Jan 24 '13 at 18:08
  • In themeas are only black and white :D. Yu can change bg color in layou xml. http://stackoverflow.com/questions/7378636/setting-background-colour-of-android-layout-element . – TN888 Jan 24 '13 at 18:13
  • it was useful but didn't answered my question – elichai2 Jan 24 '13 at 18:18
  • repeat your question in one sentence : – TN888 Jan 24 '13 at 18:20
  • 1
    I want to know want is the background color in my app.I have no background color in the xml or the java code and in the styles.xml it's just says that the them is "android:Theme.Light". – elichai2 Jan 24 '13 at 18:24
  • 1
    So why when i do a WebView and show an HTML test file so it's more white then the layout background?(Edit: in "Theme.Holo.Light" it's white too?) – elichai2 Jan 24 '13 at 18:37
0

The default background color for light theme is: #e6FFFFFF

Julio Rahman
  • 29
  • 1
  • 4