第三方PDF查看--本地查看

本地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

将这两个文件夹中的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);

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值