Android的PDF阅读器适合屏幕

Android的PDF阅读器适合屏幕

本文介绍了MuPDF Android的PDF阅读器适合屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我成功地安装了MuPDF我的Andr​​oid应用之一。但存在的问题是,在呈现我不能容纳的PDF到屏幕上。任何人都可以请建议我如何实现这一目标。谢谢!

I succesfully installed MuPDF for one of my Android Apps. But the problems is, while rendering I cannot fit the PDF to the screen. Can anybody please suggest me how to achieve this. Thanks!

推荐答案

编辑在ReaderView.java的measureView方法就成。

Edit the measureView method in ReaderView.java to become.

private void measureView(View v) {
        // See what size the view wants to be
        v.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
        // Work out a scale that will fit it to this view
        float scale;
        if (getWidth()>getHeight())
        {
            scale = (float)getWidth()/(float)v.getMeasuredWidth();
            MIN_SCALE = (float)v.getMeasuredWidth()/(float)getWidth();
            MAX_SCALE = MIN_SCALE*5.0f;
        }
        else
            scale = Math.min((float)getWidth()/(float)v.getMeasuredWidth(),
                        (float)getHeight()/(float)v.getMeasuredHeight());

        // Use the fitting values scaled by our current scale factor
        v.measure(View.MeasureSpec.EXACTLY | (int)(v.getMeasuredWidth()*scale*mScale),
                View.MeasureSpec.EXACTLY | (int)(v.getMeasuredHeight()*scale*mScale));
    }

这篇关于MuPDF Android的PDF阅读器适合屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 16:29