怎样设置web视图的背景图像上的科尔多瓦/ PhoneGap的Andr​​oid版? [英] How do I set a background image on the WebView on Cordova/PhoneGap for Android?

查看:132
本文介绍了怎样设置web视图的背景图像上的科尔多瓦/ PhoneGap的Andr​​oid版?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不只是寻找API中的开机画面功能;如果可能的话,我想的HTML内容使用透明背景,并依靠web视图提供背景图像。这样的事情可能吗?

I'm not just looking for the Splash Screen functionality in the API; if possible, I would like the HTML content to use a transparent background, and lean on the WebView to supply the background image. Is such a thing possible?

除了上述,我可以至少设置,将流血通过为HTML内容的WebView背景颜色?

Barring that, can I at least set a background color on the WebView that will "bleed through" to HTML content?

推荐答案

想通挖科尔多瓦来源和Android文档后出来。在SRC / COM /.../ MyApp.java:

Figured it out after digging in Cordova source and Android docs. In src/com/.../MyApp.java:

public class MyApp extends DroidGap
{
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);

        super.loadUrl(Config.getStartUrl(), 20000);

        // Must be after loadUrl!
        super.appView.setBackgroundColor(0x00000000); // transparent RGB
        super.appView.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null);

        // Put background image in res/drawable/splash.jpg
        Drawable theSplash = getResources().getDrawable(R.drawable.splash);
        super.root.setBackground(theSplash);
    }
}

和CSS的:

html,
body,
.transparent { background-color: transparent !important; }

这篇关于怎样设置web视图的背景图像上的科尔多瓦/ PhoneGap的Andr​​oid版?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆