Android 5 上的 Titanium webview 渲染不正确
Titanium webview rendering incorrectly on Android 5
我的 android phone(Samsung Galaxy S5,AT&T)刚刚从 Android 4.4 更新到 5.0,现在无法在 Titanium 中呈现网页视图。我有一个已发布的应用程序在 Android 4.4 上运行良好,但现在在 5.0 中无法正确呈现(相同 phone,应用程序代码没有更改)。具体来说,window 似乎自动具有比其默认值 canvas 更大的高度和宽度(至少是屏幕尺寸的 4 倍),并且将 div 自动换行和格式化为绝对位置不起作用.以前,canvas 是屏幕的宽度,因此会出现换行,window 的高度是 window 中内容的高度。我用下面的 Alloy 代码在我的 phone 上重现了错误:
<Alloy>
<Window title="Test">
<WebView id="web1" html="<html><head></head><body><p>This is a long paragraph that should have word wrap once it reaches the right side of the screen, but unfortunately the new version of Android seems to be preventing this behavior, which is peculiar, as issues did not arise with prior versions of Android, as far as I can tell.</p></body</html>" class="webclass" backgroundColor="transparent" />
</Window>
</Alloy>
如有任何帮助,我们将不胜感激。
我有同样的问题,我搜索了很多,发现它取决于设备上的 运行 OS。
尝试在 js
文件中添加这段代码,它不会解决问题,但它应该进行自动换行和放大。
var htmlText = "<p>This is a long paragraph that should have word wrap once it reaches the right side of the screen, but unfortunately the new version of Android seems to be preventing this behavior, which is peculiar, as issues did not arise with prior versions of Android, as far as I can tell.</p>"
if(OS_ANDROID) htmlText = '<html><body><div style="width:' +
(Titanium.Platform.displayCaps.platformWidth - 20) + 'px; height:auto;">' +
htmlText + '</div></body></html>';
$.webView.html = htmlText;
将以下代码添加到每个 HTML 文件似乎可以在 Android 的各种版本中创建一致的 HTML 渲染,并确保屏幕宽度合适:
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
我的 android phone(Samsung Galaxy S5,AT&T)刚刚从 Android 4.4 更新到 5.0,现在无法在 Titanium 中呈现网页视图。我有一个已发布的应用程序在 Android 4.4 上运行良好,但现在在 5.0 中无法正确呈现(相同 phone,应用程序代码没有更改)。具体来说,window 似乎自动具有比其默认值 canvas 更大的高度和宽度(至少是屏幕尺寸的 4 倍),并且将 div 自动换行和格式化为绝对位置不起作用.以前,canvas 是屏幕的宽度,因此会出现换行,window 的高度是 window 中内容的高度。我用下面的 Alloy 代码在我的 phone 上重现了错误:
<Alloy>
<Window title="Test">
<WebView id="web1" html="<html><head></head><body><p>This is a long paragraph that should have word wrap once it reaches the right side of the screen, but unfortunately the new version of Android seems to be preventing this behavior, which is peculiar, as issues did not arise with prior versions of Android, as far as I can tell.</p></body</html>" class="webclass" backgroundColor="transparent" />
</Window>
</Alloy>
如有任何帮助,我们将不胜感激。
我有同样的问题,我搜索了很多,发现它取决于设备上的 运行 OS。
尝试在 js
文件中添加这段代码,它不会解决问题,但它应该进行自动换行和放大。
var htmlText = "<p>This is a long paragraph that should have word wrap once it reaches the right side of the screen, but unfortunately the new version of Android seems to be preventing this behavior, which is peculiar, as issues did not arise with prior versions of Android, as far as I can tell.</p>"
if(OS_ANDROID) htmlText = '<html><body><div style="width:' +
(Titanium.Platform.displayCaps.platformWidth - 20) + 'px; height:auto;">' +
htmlText + '</div></body></html>';
$.webView.html = htmlText;
将以下代码添加到每个 HTML 文件似乎可以在 Android 的各种版本中创建一致的 HTML 渲染,并确保屏幕宽度合适:
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">