Pdf Viewer单击时仅显示白屏

时间:2018-07-30 14:35:58

标签: android

我试图从存储中读取文件。我使用 com.github.barteksc:android-pdf-viewer:3.1.0-beta.1 这个库在存储中的应用中显示pdf,但仅显示白屏 代码在这里

public class pdfview extends Activity {

PDFView pdfview1;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
   setContentView(R.layout.pdfreader);
    pdfview1 = (PDFView) findViewById(R.id.pdfView);
    String path = Environment.getExternalStorageDirectory() + "/" + "android" + "/" + "Data" + "/" + "FolderName" + "/" + "example.pdf";

    pdfview1.fromFile(new File(path))
            .defaultPage(0)
            .spacing(10)
            .load();
}

}

我不知道为什么它只显示白屏。 XML文件

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal"
android:background="@color/balc">


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

</com.github.barteksc.pdfviewer.PDFView>

0 个答案:

没有答案
相关问题