【问题标题】:Android open pdf in webviewAndroid在webview中打开pdf
【发布时间】:2014-01-22 14:09:57
【问题描述】:

我尝试在 webview 中打开 .pdf 文件。我编写了可以在 webview 中显示 pdf 的代码。

我正在使用“http://docs.google.com/gview?embedded=true&url=”谷歌驱动器在 docs.google 上打开 pdf 文件,但我想更改 webview 设计,例如我想更改 webview 的标题、颜色等。

我的网页视图如下所示:

http://postimg.org/image/cpb46c80x/

代码

public class MainActivity extends Activity 
{

    public WebView web;

...

@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_main);

    web = (WebView) findViewById(R.id.webView1);
    web.getSettings().setJavaScriptEnabled(true);
    // web.getSettings().setPluginState(PluginState.ON);

    web.setWebViewClient(new WebViewClient());

    String pdfURL = "http://dl.dropboxusercontent.com/u/37098169/Course%20Brochures/AND101.pdf";
    web.loadUrl("http://docs.google.com/gview?embedded=true&url="
            + pdfURL);
    // setContentView(web);
    }
}

【问题讨论】:

    标签: android pdf


    【解决方案1】:

    试试这个。

    mWebView.setWebViewClient(new WebViewClient() {
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                view.loadUrl(url);
                return false;
            }
        });
    

    【讨论】:

    • 谢谢,但我也试过了,但我不知道如何更改设计。例如,webview 的标题颜色为蓝色,我如何更改颜色?如果你知道我可以如何改变帮助,请
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-05-30
    • 2018-07-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-09
    相关资源
    最近更新 更多