gpt4 book ai didi

android - MuPDF Android Pdf 适合屏幕

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:09:24 26 4
gpt4 key购买 nike

我为我的一个 Android 应用程序成功安装了 MuPDF。但问题是,在渲染时我无法让 PDF 适合屏幕。谁能建议我如何实现这一目标。谢谢!

最佳答案

编辑ReaderView.java中的measureView方法成为。

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));
}

关于android - MuPDF Android Pdf 适合屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21063005/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com