ale*_*2k8 6 android viewport width webview
使用下面的html我预计绿色矩形只占据屏幕的一半,但实际上它占据整个屏幕宽度.我为视口宽度尝试了其他值,没有运气.任何想法为什么它不起作用?
HTML
<html>
<head>
<meta name="viewport" content="width=640" />
</head>
<body>
<div style="width: 300px; height: 50px; background: green;">300px</div>
<div style="width: 600px; height: 50px; background: yellow;">600px</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<WebView
android:id="@+id/web_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
Ale*_*sky 13
我有同样的问题,找到了答案!
在您的情况下,您需要:
WebSettings settings = webView.getSettings();
settings.setUseWideViewPort(true);
settings.setLoadWithOverviewMode(true);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13026 次 |
| 最近记录: |