What is the default layout background
Asked Answered
C

7

85

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!

Conjoined answered 24/1, 2013 at 17:39 Comment(5)
The default background color of an Android layout? I think it's nothing, or in other words black.Hornwort
Its black. Unless I'm misunderstanding your question.Grotesquery
I edited the Question please look again.Conjoined
the background color is based on your application theme, and is not a color at all, but rather a drawable. what were you trying to achieve once you found out what the color is?Negation
i want to change the html color to the same color like outside the html.Conjoined
D
185

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

Dessalines answered 18/2, 2015 at 18:11 Comment(5)
It's the #EEEEEE still in android studio latest version. Thumbs up for this answer, thank you!Mechellemechlin
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 projectDessalines
#FAFAFA +1 for me, emulator API 25, Theme.AppCompat.Light.NoActionBarAllot
Thank you! May I ask where you can find this information, just in case it changes in the future?Cultural
@Cultural is either an image editing tool or is it a source codeDessalines
D
127

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

?android:colorBackground
Draggle answered 8/2, 2017 at 14:39 Comment(1)
android:background="?android:colorBackground" Works great! Any drawbacks with this solution?Pedometer
N
33

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" >
Negation answered 24/1, 2013 at 18:31 Comment(1)
No i don't want to change the background i want to know what is the background color.Conjoined
B
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

Broadcast answered 24/11, 2016 at 21:18 Comment(0)
A
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.

Almsgiver answered 24/1, 2013 at 17:44 Comment(6)
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!Conjoined
In themeas are only black and white :D. Yu can change bg color in layou xml. #7379136 .Almsgiver
it was useful but didn't answered my questionConjoined
repeat your question in one sentence :Almsgiver
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".Conjoined
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?)Conjoined
T
0

The default background color for light theme is: #e6FFFFFF

Tanana answered 7/10, 2019 at 6:57 Comment(0)
B
0

Default color for every layout in the latest update of android studio is: #FFFFFF

Bulahbulawayo answered 10/9, 2023 at 7:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.