[英]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.