Luk*_*nis 3 android webview cordova
我不只是在寻找API中的Splash Screen功能; 如果可能的话,我希望HTML内容使用透明背景,并依靠WebView提供背景图像.这样的事情可能吗?
除此之外,我是否至少可以在WebView上设置一个"渗透"到HTML内容的背景颜色?
在挖掘Cordova源代码和Android文档后想出来.在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);
}
}
Run Code Online (Sandbox Code Playgroud)
而CSS:
html,
body,
.transparent { background-color: transparent !important; }
Run Code Online (Sandbox Code Playgroud)