我需要在Android的SplashScreen上显示动画。我想调整它的屏幕高度。我可以成功适合使用webView和javascript进行屏幕显示。但我不能改变其大小:)如何在JavaScript或HTML中调整GIF动画
我写我的代码,也许有人会需要它..
这是index.html的HTML代码(我可以把它写在Java中,但我不能显示动画,GIF在使用)
function resize(image)
{
var differenceHeight = document.body.clientHeight - image.clientHeight;
var differenceWidth = document.body.clientWidth - image.clientWidth;
if (differenceHeight < 0) differenceHeight = differenceHeight * -1;
if (differenceWidth < 0) differenceWidth = differenceWidth * -1;
if (differenceHeight > differenceWidth)
{
image.style['height'] = document.body.clientHeight + 'px';
}
else
{
image.style['width'] = document.body.clientWidth + 'px';
}
// Optional: remove margins or compensate for offset.
image.style['margin'] = 0;
document.body.style['margin'] = 0;
}
οnlοad="resize(this);"/>
,这是我的WebView:
WebView webView = (WebView) findViewById(R.id.webView);
webView.getSettings().setJavaScriptEnabled(true);
webView.setVerticalScrollBarEnabled(false);
webView.loadUrl("file:///android_asset/html/index.html");
2012-12-02
atasoyh
+0
我对什么不工作感到困惑。这似乎应该是做你想做的... –
+0
宽度是好的,但动画的高度比屏幕的长度更长 –