Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/227.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
Webview在android中全屏显示_Android - Fatal编程技术网

Webview在android中全屏显示

Webview在android中全屏显示,android,Android,我想使用以下代码在Webview中查看pdf我可以查看它,但问题是它会打开一个占据整个屏幕的新视图。我希望要查看的pdf应仅在Webview中打开,而不是在新窗口中打开。 我正在使用以下代码: webView = (WebView) findViewById(R.id.webView); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setPlugin

我想使用以下代码在Webview中查看pdf我可以查看它,但问题是它会打开一个占据整个屏幕的新视图。我希望要查看的pdf应仅在Webview中打开,而不是在新窗口中打开。 我正在使用以下代码:

        webView = (WebView) findViewById(R.id.webView);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setPluginsEnabled(true);
        String pdf = "http://178.239.16.28/fzs/sites/default/files/dokumenti-vijesti/sample.pdf";
        String url = "http://docs.google.com/gview?embedded=true&url=" + pdf;
        webView.loadUrl(url);
下面是我的xml文件:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >


       <RelativeLayout
        android:id="@+id/header_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/pdf_top_box" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:text="Title"
            android:textColor="#ffffff" />

        <Button
            android:id="@+id/back_pdf"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:layout_marginLeft="10dp"
            android:background="@drawable/back_pdf" />
    </RelativeLayout>

<WebView
    android:id="@+id/webView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/header_layout"
    />


</RelativeLayout>

试试这种方法

webView = (WebView) findViewById(R.id.webView);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setPluginsEnabled(true);
        String pdf = "http://178.239.16.28/fzs/sites/default/files/dokumenti-vijesti/sample.pdf";
        String url = "http://docs.google.com/gview?embedded=true&url=" + pdf;
        webView.setWebViewClient(new WebViewClient()); //UPDATE HERE
        webView.loadUrl(url);

是什么让你认为你可以在Android网络视图中打开PDF?