本地pdf文件查看,需下载到本地,
git地址:https://github.com/barteksc/AndroidPdfViewer
gradle :compile 'com.github.barteksc:android-pdf-viewer:1.3.0'
兼容性好,加载快,但是很大16m左右,一个so文件就有5m左右,所以想以jar包形式引入工程,删掉不必要的so文件
找到gralde保存本地路径:C:\Users\lei\.gradle\caches\modules-2\files-2.1\com.github.barteksc
找到这个文件夹,里面有两个文件夹
pdfium-android 解析pdf的核心,调用的本地方法
android-pdf-viewer 基于上面封装好的pdfview直接可以用的,我们就使用这里的PDFview
![](https://img-blog.csdn.net/20160722140611159)
将这两个文件夹中的jar包拷出来,解压,放到你的项目中去(为什么不直接用jar包呢?我也想用,可是运行一直报错解析不了pdfview这个控件,只有解压copy进去才不会崩。。)
注意:这里有个scrollBar类里面资源引用找不到,你需要将其copy到你资源中(attrs)去
<!--pdf中的-->
<declare-styleable name="ScrollBar">
<attr name="sb_handlerColor" format="color|reference" />
<attr name="sb_indicatorColor" format="color|reference" />
<attr name="sb_indicatorTextColor" format="color|reference" />
<attr name="sb_horizontal" format="boolean|reference" />
</declare-styleable>
将之前compile的工程apk解压出来,按照你想保留的so文件copy进去,就好了,瞬间apk就小了不少,
使用方法,在xml中使用PDFView,在activity中:
pdfView.fromFile(file).defaultPage(1).swipeVertical(true);