Java Android PDF scrollview单个连续页面
在xcode中,我可以将PDF显示为一个连续的页面,PDF宽度等于屏幕宽度,然后垂直卷轴的高度等于所述宽度的PDF。没问题 目前正在将相同的应用程序转换为Android,并且在实现相同的PDF视图时遇到一些困难 基本上我有一个很长的PDF页面(单页)。我不想在页面之间滑动,而是像在我的iOS应用程序中一样,让PDF文档在Android屏幕上按宽度填充,然后垂直滚动以显示PDF的其余部分 我正在使用com.github.barteksc.pdfviewer.PDFView呈现我的PDF 在活动的xml中,我有:Java Android PDF scrollview单个连续页面,java,android,pdf,scroll,Java,Android,Pdf,Scroll,在xcode中,我可以将PDF显示为一个连续的页面,PDF宽度等于屏幕宽度,然后垂直卷轴的高度等于所述宽度的PDF。没问题 目前正在将相同的应用程序转换为Android,并且在实现相同的PDF视图时遇到一些困难 基本上我有一个很长的PDF页面(单页)。我不想在页面之间滑动,而是像在我的iOS应用程序中一样,让PDF文档在Android屏幕上按宽度填充,然后垂直滚动以显示PDF的其余部分 我正在使用com.github.barteksc.pdfviewer.PDFView呈现我的PDF 在活动的x
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
tools:context=".ProfileActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.github.barteksc.pdfviewer.PDFView
android:id="@+id/pdfView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
</ScrollView>
工具:context=“.ProfileActivity”>
我曾尝试将scrollView、Linear和pdf的布局高度更改为“wrap\u content”,这似乎是合适的,但每当我这样做时,我都会看到一个空白屏幕。这样做似乎不会导致任何高度属性,因此视图会完全折叠
我得到:
我想要的是:
如果能得到更多的帮助,我将不胜感激,这是我唯一的症结所在。我希望android有PDFKit(类似的),因为我发现它非常易于使用和实现 我必须“升级”到最新版本:3.1.0-beta.1,并使用:
.pageFitPolicy(FitPolicy.WIDTH)
结合我的XML:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
tools:context=".AboutActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical">
<com.github.barteksc.pdfviewer.PDFView
android:id="@+id/pdfView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
</ScrollView>
工具:context=“.AboutActivity”>
工作得很好。我希望这对其他人有所帮助PSPDFKit出现。或者,您的内容应该表示为一个单独的网页,您可以使用
WebView
来呈现该网页。感谢Commonware,由于费用问题,我宁愿不使用PSPDFKit。关于WebView,请您扩展一下好吗?嗯,网页自然是以连续垂直滚动模式运行的。例如,滚动此网页。也许你的内容可以是HTML/CSS/JS格式,而不是PDF格式。对不起,这是一个多么荒谬的评论……问题是关于PDF的,我到底为什么要将内容更改为HTML。。事实上与这个问题无关,只是浪费我的时间。如果我能否决一条评论,我会无数次地说“我到底为什么要把内容改成HTML”——因为它符合你想要的呈现模式,而且是免费的。因此,现在您正在寻找一种解决方案,强制使用内容格式、呈现模式和价格点。如果您最终不得不实现更低级的东西来实现这一组合,例如,如果没有用于连续垂直滚动的内置选项,那么您将为您尝试使用的开放源代码库提供补丁,请不要感到惊讶。