【发布时间】:2013-08-14 12:47:11
【问题描述】:
在我的应用程序中,它有一个网页视图和链接按钮。
如果我点击按钮,webview 会加载目标页面。
有些页面适合 webview 并且看起来不错,但有些则不然。
在每个加载的页面中,他们都有这个
<meta name="viewport" content="width=device-width, initial-scale=0.8">
所以它们应该看起来都一样:(
我的代码有什么问题?
public class MainActivity extends Activity {
private ActionBar mActionBar;
private SimpleSideDrawer mNav;
WebView myWebView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myWebView = (WebView)findViewById(R.id.webView1);
myWebView.setWebViewClient(new WebViewClient());
myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.loadUrl("http://example-site.com/");
myWebView.getSettings().setSupportZoom(true);
myWebView.getSettings().setLoadWithOverviewMode(true);
myWebView.getSettings().setUseWideViewPort(true);
}
}
//This will be called when the button is clicked
public void loadThisUrl(String url) {
mNav.closeLeftSide();
mNav.closeRightSide();
myWebView.loadUrl(url);
}
更新
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<WebView
android:id="@+id/webView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
【问题讨论】:
-
要在 Webview 中安装网页,请参阅 stackoverflow.com/questions/3916330/…
-
@Sameer 我试过了,但它返回了这个错误
PIC_WIDTH cannot be resolved to a variable -
你可以为 webview 发布你的 xml 吗?
-
@Shrikant 当然。我不知道如何定义 PIC_WIDTH
-
@Shrikant 我在我的问题中添加了更新。谢谢
标签: android