什么是默认布局背景

问题描述 投票:48回答:5

我有一个WebView加载带有文本的HTML文件。问题是html和外部的颜色不一样。这是一个截图:

HTML文件是:

<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>

(如果我删除:bgcolor="#FFFFFF"颜色保持不变)谢谢!

android html android-layout background-color
5个回答
133
投票

灯光主题的默认背景颜色为:#EEEEEE

几乎是白色,但不完全。

它对我有用,希望它为你工作。

更新:在新版本中,您可能正在寻找#FAFAFA


70
投票

您可以通过引用来使用主题的默认背景颜色:

?android:colorBackground

24
投票

要改变你的背景(如果这实际上是你想要做的):

在styles.xml中

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

在你的清单中

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

13
投票

去Manifest

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

你看主题是MyMaterialTheme.NoActionBar

所以去res - > values - > styles Click open in editor

Click on the pallette for the background color

This is your background color

所以对我来说默认是#FFFAFAFA

当我把建议的颜色#EEEEEE或#FAFAFA,它在一些手机上工作,而在其他手机上它是关闭的,所以这是我在试验中发现的


2
投票

默认颜色为黑色。

如果您使用样式,请转到“values / styles.xml”并找到您的解决方案。现在你可以查看bg颜色了。关于主题和风格:http://developer.android.com/guide/topics/ui/themes.html

编辑:

布局背景颜色变化 - Setting background colour of Android layout element

编辑2:

如果styles.xml是@android:style / Theme.Light你的bg颜色是白色。

© www.soinside.com 2019 - 2024. All rights reserved.