首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在PDFView中设置垂直滚动(com.github.barteksc.pdfviewer.PDFView)

如何在PDFView中设置垂直滚动(com.github.barteksc.pdfviewer.PDFView)
EN

Stack Overflow用户
提问于 2017-09-22 01:54:28
回答 2查看 3K关注 0票数 1

我正在尝试com.github.barteksc.pdfviewer.PDFView的PDFView。

我有一个有几个按钮的ScrollView,在这些按钮的中间是PDFView。

PDFView是一个5页的PDF文件。

问题是当运行应用程序时,滚动到PDFView,我只能看到PDF文件的第一页。

如何滚动到PDFView,然后在PDFView中滚动?

谢谢。

图片来源:https://drive.google.com/open?id=0B2QkD8wCK_jqX2d0YlFVT2J3X2M

代码:

代码语言:javascript
复制
package gmm.formulariogmm;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.Toast;

import com.github.barteksc.pdfviewer.PDFView;


public class PDFViewDemo extends AppCompatActivity {

PDFView pdfView;

@Override
public void onCreate(Bundle savedInstanceState) {


        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_pdfview);

        pdfView = (PDFView) findViewById(R.id.pdfView);
        pdfView.fromAsset("test.pdf").load();

}
};//Fin

布局:

代码语言:javascript
复制
<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <Button
            android:id="@+id/button1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Button1" />

        <Button
            android:id="@+id/button2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Button2" />

        <Button
            android:id="@+id/button3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Button3" />

        <Button
            android:id="@+id/button4"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Button4" />

        <com.github.barteksc.pdfviewer.PDFView
            android:id="@+id/pdfView"
            android:layout_width="match_parent"
            android:layout_height="300dp" />

        <Button
            android:id="@+id/button5"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Button5" />

        <Button
            android:id="@+id/button6"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Button6" />
    </LinearLayout>

</ScrollView>
EN

回答 2

Stack Overflow用户

发布于 2020-09-06 06:18:47

您必须启用卷帘,并将垂直卷帘设置为true。就像这样。

代码语言:javascript
复制
pdfView.fromAsset(bookName)
            .enableSwipe(true)
            .swipeVerticle(true)
.load();

谢谢

票数 0
EN

Stack Overflow用户

发布于 2018-02-07 20:40:18

代码语言:javascript
复制
pdfView.fromAsset(SAMPLE_FILE)
            .defaultPage(pageNumber)
            .enableSwipe(true)
            .enableDoubletap(true)
            .swipeVertical(false)
            .showMinimap(false)
            .onRender(new OnRenderListener() {
             @Override
             public void onInitiallyRendered(int pages, float pageWidth, 
             float pageHeight) {
            pdfview.fitToWidth(); // optionally pass page number
              }
             });
             .onLoad(this)
             .scrollHandle(new DefaultScrollHandle(this))
            .load();
票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46350332

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档