8

我想知道你们在打开应用程序内的网页方面会推荐什么(即一个较小的窗口,其中打开一个网页但不是网络浏览器)我试图或多或少地将我的网页集成到我的应用程序中。谢谢 :)

4

2 回答 2

10

您是否尝试过使用WebView布局?

在您的布局文件中:

<?xml version="1.0" encoding="utf-8"?>
<WebView  xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/webview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
/>

将权限包含在INTERNET您的清单中:

<uses-permission android:name="android.permission.INTERNET" />

然后在您的活动中:

WebView myWebView = (WebView) findViewById(R.id.webview);
myWebView.loadUrl("http://www.example.com");

这会将网络浏览器嵌入到您的应用程序中(而不是打开外部浏览器)。

于 2013-09-03T00:31:29.263 回答
2

您可以放置​​视图组,然后将 webview 放入其中并根据需要修改大小

<LinearLayout
    android:orientation="vertical"
    android:gravity="center"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
 <WebView
         android:id="@+id/webView"
         android:layout_width="fill_parent"
         android:layout_height="fill_parent">

 </WebView>
</LinearLayout>

在您的清单文件中授予权限

<uses-permission android:name="android.permission.INTERNET" />

然后你从代码中获取对象

WebView myWebView = (WebView) findViewById(R.id.webview);
myWebView.loadUrl("http://www.google.com");
于 2013-09-03T02:44:30.623 回答