Ant*_*ine 10 android webview android-4.4-kitkat
我在使用Android 4.4的WebView中遇到了问题.在KitKat之前,文本自动适应webview中的所有设备分辨率.但今天它不再适合自动装配4.4.我认为这是因为基于Chromium和KitKat的WebView更新.
以下是同一页面的2个屏幕截图:
一个来自Nexus 5(Android 4.4和基于Chromium的WebView)
你知道在webview中是否有一个新选项可以在屏幕上显示文本吗?
注意:我不认为我的布局与我的问题有关,但无论如何它在这里:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
Mat*_*unt 13
它看起来像是在使用NARROW_COLUMNS.这在KitKat 中已弃用.
但是,添加了一个新的布局算法,可以解决这个问题,这里有一个例子:https: //github.com/GoogleChrome/chromium-webview-samples
主要代码是:
// Use WideViewport and Zoom out if there is no viewport defined
settings.setUseWideViewPort(true);
settings.setLoadWithOverviewMode(true);
settings.setLayoutAlgorithm(LayoutAlgorithm.TEXT_AUTOSIZING);
Run Code Online (Sandbox Code Playgroud)
另一个选项是启用捏缩放:
// Enable pinch to zoom without the zoom buttons
settings.setBuiltInZoomControls(true);
if(Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) {
// Hide the zoom controls for HONEYCOMB+
settings.setDisplayZoomControls(false);
}
Run Code Online (Sandbox Code Playgroud)
新的布局算法可能无法解决所有问题,并且不清楚如何可靠地模仿旧的包装行为.
大多数反对意见似乎是在移动设备上显示桌面网站的一般浏览器问题.他们喜欢旧的方式,但我还没有看到其他浏览器做文本包装算法正在做的事情.
| 归档时间: |
|
| 查看次数: |
9286 次 |
| 最近记录: |