[英]Android PDF scrollview single continuous page
在xcode中,我可以将PDF显示为单个连续页面,PDF宽度等于屏幕宽度,然后垂直滚动是所述宽度的PDF高度。 没问题
目前正在将相同的应用程序转换为Android,并且在实现相同的PDF视
基本上我有一个很长的PDF页面(单页)。 我不想在页面之间滑动,但是在我的iOS应用程序中,让PDF文档明智地填充Android屏幕,然后垂直滚动以显示其余的PDF
我正在使用com.github.barteksc.pdfviewer.PDFView来呈现我的PDF
在我的xml中,我有以下活动:
<?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>
我已经尝试将layout_height更改为scrollView,Linear和pdf的“wrap_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>
工作得很完美。 我希望这有助于其他人
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.