coo*_*max 13 android webview android-webview
我想在android的webview中呈现一个网页.目前,我可以显示网页,但如何使其适合屏幕?我提到: Android Webview - 网页应该适合设备屏幕, 但没有找到解决方案.
谢谢!!
小智 29
对我有用的唯一方法就是这样:
webView = (WebView) findViewById(R.id.noticiasWebView);
webView.setInitialScale(1);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
webView.setScrollbarFadingEnabled(false);
webView.loadUrl("http://www.resource.com.br/");
Run Code Online (Sandbox Code Playgroud)
我正在使用Android 2.1,因为该公司提供的设备类型.但我使用每个信息的一部分解决了我的问题.
小智 8
我的解决方案不同.我制作了一个足够大的网页,然后它会被缩小.在webview设置中,我提出以下内容:
WebView webview = new WebView(this);
//webview.setInitialScale(100); No need for this one
WebSettings settings = webview.getSettings();
settings.setBuiltInZoomControls(false);
settings.setUseWideViewPort(true);
settings.setJavaScriptEnabled(true);
settings.setSupportMultipleWindows(true);
settings.setJavaScriptCanOpenWindowsAutomatically(true);
settings.setLoadsImagesAutomatically(true);
settings.setLightTouchEnabled(true);
settings.setDomStorageEnabled(true);
settings.setLoadWithOverviewMode(true);
Run Code Online (Sandbox Code Playgroud)
请务必导入以下内容: import android.webkit.WebSettings.ZoomDensity;
您的问题不是很清楚,但如果我猜您的意思是webview没有扩展以适应整个屏幕?请发布您的代码来支持您的问题。
要扩展webview到整个屏幕,请webview在活动布局 xml 中添加 并确保将layout_width和设置layout_height为 fill_parent。这是一个简单的例子:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<WebView
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
瑞安
| 归档时间: |
|
| 查看次数: |
47476 次 |
| 最近记录: |