Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/220.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Android中显示具有主题对话框样式的WebView_Android_Dialog_Themes_Webview - Fatal编程技术网

如何在Android中显示具有主题对话框样式的WebView

如何在Android中显示具有主题对话框样式的WebView,android,dialog,themes,webview,Android,Dialog,Themes,Webview,我在清单中声明了一个WebView活动,如下所示: <activity android:name=".MyWebView" android:label="@string/app_name" android:configChanges="orientation|keyboardHidden" android:theme="@android:style/Theme.Dialog"> </activity> <?xml version="1.0"

我在清单中声明了一个WebView活动,如下所示:

<activity android:name=".MyWebView"
    android:label="@string/app_name"
    android:configChanges="orientation|keyboardHidden"
    android:theme="@android:style/Theme.Dialog">
</activity>
<?xml version="1.0" encoding="utf-8"?>

<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>

WebView如下所示:

<activity android:name=".MyWebView"
    android:label="@string/app_name"
    android:configChanges="orientation|keyboardHidden"
    android:theme="@android:style/Theme.Dialog">
</activity>
<?xml version="1.0" encoding="utf-8"?>

<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>

当我在主活动中启动此活动时,只有包含应用程序名称的对话框标题可见,但在WebView中不可见。如果我将文本视图添加到LinearLayout,它也会显示,但仍然缺少WebView。 如果我没有在清单中应用
android:theme=“@android:style/theme.Dialog”
,将显示WebView


这是为什么?我如何在对话框中显示网络视图?

我认为您所做的工作会起作用。可能尝试覆盖dialog类而不是activity类。

我发现,如果您将webview更改为包装内容而不是填充父对象,则它会起作用。不知道为什么。这可能是一个bug。

使用WebView作为根布局-没有任何周围元素。
不知道为什么它不能与周围的布局配合使用。

我发现最好的方法是这样一个小技巧:

<activity android:name=".MyWebView"
    android:label="@string/app_name"
    android:configChanges="orientation|keyboardHidden"
    android:theme="@android:style/Theme.Dialog">
</activity>
<?xml version="1.0" encoding="utf-8"?>

<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>
注意minWidth和minHeight的1000dp

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:minWidth="1000dp"
          android:minHeight="1000dp" >

    <WebView android:id="@+id/web_view"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent" />

</LinearLayout>


另一种方法是在WebView上包装内容,但在加载网页之前它不会扩展。因此,它将从小开始,然后扩展。这种粗制滥造的方式会在一开始就创建一个大对话框。

无论哪种方式,我都无法让它工作。你能举个工作的例子吗?很好,对我来说很有用。:)它需要一段时间,直到WebView显示(所以,只有标题在第一),但也许我会添加一个无限的进展,而网站正在加载。