次のコードを使用して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>